ReportFieldMapper.xml 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  3. <mapper namespace="cn.cslg.report.mapper.ReportFieldMapper">
  4. <sql id="Patent_Query_Source_Base_Select">
  5. select ifnull(${label}, '未选择') as label, count(${count}) as `count`, ifnull(${value}, 'null') as `value`,
  6. group_concat(distinct a.id) as ids
  7. from os_patent a
  8. <if test="params.folder != null and params.folder != ''">
  9. left join os_portfolio_link b on b.pid = a.id
  10. </if>
  11. <if test="params.folder == null or params.folder == ''">
  12. left join os_thematic_pid b on b.pid = a.id
  13. </if>
  14. </sql>
  15. <sql id="Patent_Query_Source_Base_Where">
  16. <where>
  17. <if test="params.projectId != null">
  18. and b.zid = #{params.projectId}
  19. </if>
  20. <if test="params.folder != '' and params.folder != null">
  21. and b.fid = #{params.folder}
  22. </if>
  23. <if test="params.label != '' and params.label != null">
  24. and ${label} like concat('%', #{params.label}, '%')
  25. </if>
  26. <if test="ids != null and ids.size() != 0">
  27. and b.pid in
  28. <foreach collection="ids" item="item" separator="," open="(" close=")">
  29. #{item}
  30. </foreach>
  31. </if>
  32. </where>
  33. </sql>
  34. <sql id="Patent_Query_Source_Base_Group">
  35. group by
  36. ${groupBy}
  37. order
  38. by
  39. `${orderBy}`
  40. desc,
  41. `value`
  42. asc
  43. </sql>
  44. <select id="find" resultType="cn.cslg.report.entity.ReportField">
  45. select * from OS_PATENT_FIELD where REPORT_ID=#{reportId} and ID=#{id}
  46. </select>
  47. <delete id="deleteReportId">
  48. delete from OS_PATENT_FIELD where REPORT_ID=#{reportId} and ID=#{id}
  49. </delete>
  50. <update id="updateReportId" parameterType="cn.cslg.report.entity.ReportField">
  51. update OS_PATENT_FIELD set`NAME`=#{name},PTYPE=#{ptype},`TYPE`=#{type},STATUS=#{status},REMARK=#{remark},
  52. CID=#{createBy},CREATE_TIME=#{createTime},REPORT_TYPE=#{reportType} where REPORT_ID=#{reportId} and ID=#{id}
  53. </update>
  54. <select id="getPatentQuerySourcePageList" parameterType="cn.cslg.report.common.model.vo.PatentQueryFieldSourceVO"
  55. resultType="cn.cslg.report.common.model.dto.PatentQueryFieldSourceDTO">
  56. <if test="params.type != 'query'">
  57. select temp.* from ((
  58. <include refid="Patent_Query_Source_Base_Select">
  59. <property name="label" value="null"/>
  60. <property name="count" value="a.id"/>
  61. <property name="value" value="null"/>
  62. </include>
  63. <include refid="Patent_Query_Source_Base_Where">
  64. <property name="label" value="null"/>
  65. </include>
  66. and a.id not in (select pid from os_patent_field_patent_link where cid = #{params.customFieldId})
  67. ) union all (
  68. <include refid="Patent_Query_Source_Base_Select">
  69. <property name="label" value="d.name"/>
  70. <property name="count" value="distinct e.pid"/>
  71. <property name="value" value="d.id"/>
  72. </include>
  73. left join os_patent_field_patent_link e on e.pid = b.pid
  74. left join os_patent_field c1 on c1.id = e.cid
  75. <if test="params.type == 6">
  76. left join os_patent_field_tree d on d.cid = e.cid
  77. </if>
  78. <if test="params.type == 0 or params.type == 1 or params.type == 2">
  79. left join os_patent_field_text d on d.cid = e.cid and d.name is not null and d.name != ''
  80. </if>
  81. <if test="params.type == 3 or params.type == 4 or params.type == 5">
  82. left join os_patent_field_multiple d on d.cid = e.cid
  83. </if>
  84. <include refid="Patent_Query_Source_Base_Where">
  85. <property name="label" value="d.name"/>
  86. </include>
  87. and c1.id = #{params.customFieldId}
  88. <if test="params.customFieldTreeType == 0">
  89. and e.fid in (select id from os_patent_field_tree where cid = c1.id and find_in_set(d.id , replace(path
  90. , '/', ',')))
  91. </if>
  92. <if test="params.customFieldTreeType == null">
  93. and e.fid = d.id
  94. </if>
  95. group by d.id
  96. )) as temp where 1 = 1 order by `count` desc, `value` asc
  97. </if>
  98. </select>
  99. <select id="getFieldPatentNos" parameterType="java.util.List" resultType="java.lang.String">
  100. select distinct c.PATENT_NO from COMPARE_FILES c <where>
  101. <foreach collection="params" item="item" separator=" and ">
  102. c.PATENT_NO in (
  103. select distinct a.PATENT_NO from COMPARE_FILES a left join OS_PATENT_FIELD_PATENT_LINK b on a.PATENT_NO =b.PATENT_NO
  104. and b.CID=#{item.field}
  105. <where>
  106. a.REPORT_ID=#{reportId}
  107. and (
  108. b.FID in
  109. <foreach collection="item.optionList" item="item1" separator="," open="(" close=")">
  110. #{item1.key}
  111. </foreach>
  112. <if test="item.haveNull == 1">
  113. or b.CID is null
  114. </if>
  115. )
  116. </where>
  117. )
  118. </foreach>
  119. </where>
  120. </select>
  121. <select id="getFieldTaskPNos" parameterType="java.util.List" resultType="java.lang.String">
  122. select distinct c.PATENT_NO from COMPARE_FILES c <where>
  123. <foreach collection="params" item="item" separator=" and ">
  124. c.PATENT_NO in (
  125. select distinct a.PATENT_NO from ASSO_TASK_PATENT a left join OS_PATENT_FIELD_PATENT_LINK b on a.PATENT_NO =b.PATENT_NO
  126. and a.REPORT_ID=b.REPORT_ID and b.CID=#{item.field}
  127. <where>
  128. a.TASK_ID=#{taskId}
  129. <if test="readState!=3">
  130. and a.STATE =#{readState}
  131. </if>
  132. and (
  133. b.FID in
  134. <foreach collection="item.optionList" item="item1" separator="," open="(" close=")">
  135. #{item1.key}
  136. </foreach>
  137. <if test="item.haveNull == 1">
  138. or b.CID is null
  139. </if>
  140. )
  141. </where>
  142. )
  143. </foreach>
  144. </where>
  145. </select>
  146. </mapper>