2022-06-19 17:14:53 +08:00
|
|
|
<?xml version="1.0" encoding="UTF-8" ?>
|
2022-04-14 13:58:19 +08:00
|
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
|
|
|
|
|
<mapper namespace="io.renren.modules.resource.dao.ResourceDao">
|
|
|
|
|
|
|
|
<resultMap type="io.renren.modules.resource.entity.ResourceEntity" id="resourceMap">
|
|
|
|
<result property="id" column="id"/>
|
|
|
|
<result property="type" column="type"/>
|
|
|
|
<result property="name" column="name"/>
|
|
|
|
<result property="description" column="description"/>
|
|
|
|
<result property="link" column="link"/>
|
2022-04-26 11:51:08 +08:00
|
|
|
<result property="apiMethodType" column="api_method_type"/>
|
2022-04-25 17:53:08 +08:00
|
|
|
<result property="apiUrl" column="api_url"/>
|
|
|
|
<result property="groupId" column="group_id"/>
|
2022-04-20 17:31:48 +08:00
|
|
|
<result property="deptId" column="dept_id"/>
|
2022-04-25 14:08:34 +08:00
|
|
|
<result property="deptContacts" column="dept_contacts"/>
|
|
|
|
<result property="deptPhone" column="dept_phone"/>
|
2022-04-25 17:53:08 +08:00
|
|
|
<result property="shareType" column="share_type"/>
|
|
|
|
<result property="shareMode" column="share_mode"/>
|
|
|
|
<result property="shareCondition" column="share_condition"/>
|
2022-04-20 17:31:48 +08:00
|
|
|
<result property="districtId" column="district_id"/>
|
2022-04-14 13:58:19 +08:00
|
|
|
<result property="visits" column="visits"/>
|
|
|
|
<result property="delFlag" column="del_flag"/>
|
|
|
|
<result property="creator" column="creator"/>
|
|
|
|
<result property="createDate" column="create_date"/>
|
|
|
|
<result property="updater" column="updater"/>
|
|
|
|
<result property="updateDate" column="update_date"/>
|
|
|
|
<result property="note1" column="note1"/>
|
|
|
|
<result property="note2" column="note2"/>
|
|
|
|
<result property="note3" column="note3"/>
|
|
|
|
<result property="note4" column="note4"/>
|
|
|
|
<result property="note5" column="note5"/>
|
2022-05-18 16:13:51 +08:00
|
|
|
<result property="enclosure" column="enclosure"/>
|
|
|
|
<result property="undercarriageReason" column="undercarriage_reason"/>
|
|
|
|
<result property="undercarriageUserName" column="undercarriage_user_name"/>
|
2022-06-20 10:23:37 +08:00
|
|
|
<result property="infoList" column="info_list"
|
|
|
|
typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
|
2022-04-14 13:58:19 +08:00
|
|
|
</resultMap>
|
|
|
|
|
2022-04-14 23:51:01 +08:00
|
|
|
<resultMap id="resourceDTO" type="io.renren.modules.resource.dto.ResourceDTO">
|
|
|
|
<result property="id" column="id"/>
|
|
|
|
<result property="type" column="type"/>
|
|
|
|
<result property="name" column="name"/>
|
|
|
|
<result property="description" column="description"/>
|
|
|
|
<result property="link" column="link"/>
|
2022-04-26 11:51:08 +08:00
|
|
|
<result property="apiMethodType" column="api_method_type"/>
|
2022-04-25 17:53:08 +08:00
|
|
|
<result property="apiUrl" column="api_url"/>
|
|
|
|
<result property="groupId" column="group_id"/>
|
2022-04-20 17:31:48 +08:00
|
|
|
<result property="deptId" column="dept_id"/>
|
2022-04-25 14:08:34 +08:00
|
|
|
<result property="deptContacts" column="dept_contacts"/>
|
|
|
|
<result property="deptPhone" column="dept_phone"/>
|
2022-04-25 17:53:08 +08:00
|
|
|
<result property="shareType" column="share_type"/>
|
|
|
|
<result property="shareMode" column="share_mode"/>
|
|
|
|
<result property="shareCondition" column="share_condition"/>
|
2022-04-20 17:31:48 +08:00
|
|
|
<result property="districtId" column="district_id"/>
|
2022-04-14 23:51:01 +08:00
|
|
|
<result property="visits" column="visits"/>
|
|
|
|
<result property="delFlag" column="del_flag"/>
|
|
|
|
<result property="creator" column="creator"/>
|
|
|
|
<result property="createDate" column="create_date"/>
|
|
|
|
<result property="updater" column="updater"/>
|
|
|
|
<result property="updateDate" column="update_date"/>
|
|
|
|
<result property="note1" column="note1"/>
|
|
|
|
<result property="note2" column="note2"/>
|
|
|
|
<result property="note3" column="note3"/>
|
|
|
|
<result property="note4" column="note4"/>
|
|
|
|
<result property="note5" column="note5"/>
|
2022-05-18 16:13:51 +08:00
|
|
|
<result property="enclosure" column="enclosure"/>
|
|
|
|
<result property="undercarriageReason" column="undercarriage_reason"/>
|
|
|
|
<result property="undercarriageUserName" column="undercarriage_user_name"/>
|
2022-04-25 17:53:08 +08:00
|
|
|
<!-- 自定义字段 -->
|
2022-04-27 16:50:16 +08:00
|
|
|
<result property="deptName" column="deptName"/>
|
|
|
|
<result property="isCollect" column="isCollect"/>
|
|
|
|
<result property="collectCount" column="collectCount"/>
|
2022-04-25 17:53:08 +08:00
|
|
|
<result property="score" column="score"/>
|
2022-04-27 16:50:16 +08:00
|
|
|
<result property="applyState" column="applyState"/>
|
|
|
|
<result property="applyCount" column="applyCount"/>
|
2022-06-30 10:45:10 +08:00
|
|
|
<result property="infoList" column="info_list"
|
|
|
|
typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
|
|
|
|
<!-- <collection property="infoList" javaType="List" ofType="attrEntity">-->
|
|
|
|
<!-- <result property="id" column="id"/>-->
|
|
|
|
<!-- <result property="dataResourceId" column="data_resource_id"/>-->
|
|
|
|
<!-- <result property="attrType" column="attr_type"/>-->
|
|
|
|
<!-- <result property="attrValue" column="attr_value"/>-->
|
|
|
|
<!-- <result property="delFlag" column="del_flag"/>-->
|
|
|
|
<!-- <result property="creator" column="creator"/>-->
|
|
|
|
<!-- <result property="createDate" column="create_date"/>-->
|
|
|
|
<!-- <result property="updater" column="updater"/>-->
|
|
|
|
<!-- <result property="updateDate" column="update_date"/>-->
|
|
|
|
<!-- <result property="note1" column="note1"/>-->
|
|
|
|
<!-- <result property="note2" column="note2"/>-->
|
|
|
|
<!-- <result property="note3" column="note3"/>-->
|
|
|
|
<!-- <result property="note4" column="note4"/>-->
|
|
|
|
<!-- <result property="note5" column="note5"/>-->
|
|
|
|
<!-- </collection>-->
|
2022-04-14 23:51:01 +08:00
|
|
|
</resultMap>
|
2022-06-20 10:23:37 +08:00
|
|
|
|
2022-04-14 13:58:19 +08:00
|
|
|
<update id="deleteByIds">
|
2022-04-27 16:50:16 +08:00
|
|
|
UPDATE tb_data_resource
|
|
|
|
SET del_flag = 1,
|
|
|
|
update_date = NOW()
|
|
|
|
WHERE 1 = 1
|
2022-05-11 15:31:48 +08:00
|
|
|
AND id IN
|
2022-04-14 13:58:19 +08:00
|
|
|
<foreach collection="ids" item="item" open="(" separator="," close=")">
|
|
|
|
#{item}
|
|
|
|
</foreach>
|
|
|
|
</update>
|
|
|
|
|
2022-04-14 23:51:01 +08:00
|
|
|
<select id="selectWithAttrs" resultMap="resourceDTO">
|
|
|
|
SELECT
|
2022-06-27 19:42:02 +08:00
|
|
|
DISTINCT tdr.id,
|
2022-05-11 20:19:31 +08:00
|
|
|
IFNULL(taa2.approve_status, '未申请') AS "applyState",
|
2022-04-27 16:50:16 +08:00
|
|
|
IFNULL(trs.score, 0 ) AS "score",
|
|
|
|
IFNULL(taa.applyCount, 0 ) AS "applyCount",
|
|
|
|
IFNULL(trc.collectCount, 0) AS "collectCount",
|
2022-06-02 16:55:00 +08:00
|
|
|
IFNULL(sd.name, '暂无部门单位信息') AS "deptName",
|
2022-04-27 16:50:16 +08:00
|
|
|
IFNULL(trc2.isCollect, 'false') AS "isCollect",
|
2022-05-18 16:13:51 +08:00
|
|
|
(IFNULL(tdr.visits / 100, 0) + IFNULL(trs.score, 0) + IFNULL(taa.applyCount, 0)+ IFNULL(trc.collectCount, 0)) AS
|
|
|
|
total
|
2022-04-14 23:51:01 +08:00
|
|
|
FROM
|
2022-04-27 16:50:16 +08:00
|
|
|
tb_data_resource tdr
|
|
|
|
LEFT JOIN tb_data_attr tda ON tdr.id = tda.data_resource_id
|
2022-05-18 16:13:51 +08:00
|
|
|
LEFT JOIN ( SELECT resource_id, AVG(score) AS "score" FROM tb_resource_score WHERE 1 = 1 AND del_flag = 0 GROUP
|
|
|
|
BY resource_id ) trs ON tdr.id = trs.resource_id
|
|
|
|
LEFT JOIN ( SELECT resource_id, COUNT(id) AS "applyCount" FROM t_ability_application WHERE 1 = 1 AND del_flag =
|
|
|
|
0 GROUP BY resource_id ) taa ON tdr.id = taa.resource_id
|
|
|
|
LEFT JOIN ( SELECT resource_id, COUNT(id) AS "collectCount" FROM tb_resource_collection WHERE 1 = 1 AND del_flag
|
|
|
|
= 0 GROUP BY resource_id ) trc ON tdr.id = trc.resource_id
|
2022-06-13 17:11:58 +08:00
|
|
|
LEFT JOIN ( SELECT resource_id, user_id, ( IF(COUNT( id ) = 1, 'true', 'false') ) AS "isCollect"
|
|
|
|
FROM tb_resource_collection WHERE 1 = 1 AND del_flag = 0 AND user_id = #{dto.creator} GROUP BY resource_id
|
2022-04-27 16:50:16 +08:00
|
|
|
) trc2 ON tdr.id = trc2.resource_id
|
2022-06-13 17:11:58 +08:00
|
|
|
LEFT JOIN ( SELECT resource_id, user_id, approve_status FROM t_ability_application WHERE 1 = 1 AND del_flag = 0
|
|
|
|
AND user_id = #{dto.creator}
|
2022-05-11 20:19:31 +08:00
|
|
|
GROUP BY id) taa2 ON tdr.id = taa2.resource_id
|
2022-04-27 16:50:16 +08:00
|
|
|
LEFT JOIN sys_dept sd ON tdr.dept_id = sd.id
|
2022-04-14 23:51:01 +08:00
|
|
|
WHERE 1 = 1
|
2022-06-02 16:55:00 +08:00
|
|
|
AND tdr.del_flag = 0
|
2022-05-12 13:48:47 +08:00
|
|
|
<if test="dto.type != null and dto.type != ''">
|
2022-06-27 15:44:18 +08:00
|
|
|
AND MATCH (tdr.type) AGAINST ( #{dto.type} IN BOOLEAN MODE)
|
|
|
|
<!--AND tdr.type LIKE CONCAT('%',#{dto.type},'%') -->
|
2022-05-12 13:48:47 +08:00
|
|
|
</if>
|
2022-05-11 15:31:48 +08:00
|
|
|
<if test="dto.name != null and dto.name != ''">
|
2022-06-27 15:44:18 +08:00
|
|
|
<!-- AND tdr.name LIKE CONCAT('%',#{dto.name},'%') -->
|
|
|
|
AND MATCH (tdr.name) AGAINST ( #{dto.name} IN BOOLEAN MODE)
|
2022-04-20 17:31:48 +08:00
|
|
|
</if>
|
2022-05-11 15:31:48 +08:00
|
|
|
<if test="dto.districtId != null and dto.districtId != ''">
|
|
|
|
AND tdr.district_id = #{dto.districtId}
|
2022-04-20 17:31:48 +08:00
|
|
|
</if>
|
2022-05-19 17:22:53 +08:00
|
|
|
<if test="null != dto.deptIds and dto.deptIds.size > 0">
|
2022-05-20 11:30:29 +08:00
|
|
|
AND tdr.dept_id IN
|
|
|
|
<foreach collection="dto.deptIds" item="item" open="(" separator="," close=")">
|
|
|
|
#{item}
|
|
|
|
</foreach>
|
2022-05-19 17:22:53 +08:00
|
|
|
</if>
|
2022-05-13 17:30:05 +08:00
|
|
|
<if test="dto.shareCondition != null and dto.shareCondition != ''">
|
|
|
|
AND tdr.share_condition = #{dto.shareCondition}
|
|
|
|
</if>
|
2022-05-11 15:31:48 +08:00
|
|
|
<if test="dto.deptId != null and dto.deptId != ''">
|
|
|
|
AND tdr.dept_id = #{dto.deptId}
|
2022-04-20 17:31:48 +08:00
|
|
|
</if>
|
2022-04-15 11:49:50 +08:00
|
|
|
<if test="dto.infoList.size > 0">
|
2022-04-14 23:51:01 +08:00
|
|
|
AND
|
2022-05-11 15:31:48 +08:00
|
|
|
tda.data_resource_id IN (
|
2022-04-20 17:31:48 +08:00
|
|
|
SELECT data_resource_id
|
|
|
|
FROM (
|
2022-04-27 16:50:16 +08:00
|
|
|
SELECT tb.data_resource_id
|
|
|
|
FROM (
|
|
|
|
<foreach collection="dto.infoList" item="item" separator="union all">
|
|
|
|
SELECT data_resource_id FROM tb_data_attr
|
|
|
|
WHERE attr_type = #{item.attrType}
|
2022-06-27 15:44:18 +08:00
|
|
|
<!-- AND attr_value LIKE CONCAT('%', #{item.attrValue}, '%') -->
|
|
|
|
AND MATCH ( attr_value) AGAINST ( #{item.attrValue} IN BOOLEAN MODE)
|
2022-04-27 16:50:16 +08:00
|
|
|
AND del_flag = 0
|
|
|
|
</foreach>) tb
|
|
|
|
GROUP BY tb.data_resource_id
|
|
|
|
HAVING COUNT( tb.data_resource_id ) = ${dto.infoList.size}
|
|
|
|
) tmp
|
2022-04-20 17:31:48 +08:00
|
|
|
)
|
2022-04-14 23:51:01 +08:00
|
|
|
</if>
|
2022-04-27 16:50:16 +08:00
|
|
|
ORDER BY ${orderField} ${orderType}
|
2022-04-20 17:31:48 +08:00
|
|
|
</select>
|
2022-04-14 23:51:01 +08:00
|
|
|
|
2022-04-20 17:31:48 +08:00
|
|
|
<select id="selectTypeCount" resultType="java.util.Map">
|
2022-04-27 16:50:16 +08:00
|
|
|
SELECT
|
2022-05-11 15:31:48 +08:00
|
|
|
type,
|
|
|
|
count(id) AS "count"
|
2022-04-27 16:50:16 +08:00
|
|
|
FROM tb_data_resource
|
|
|
|
WHERE 1 = 1
|
2022-05-11 15:31:48 +08:00
|
|
|
AND del_flag = 0
|
2022-06-19 17:14:53 +08:00
|
|
|
<if test="type != null and type != ''">
|
2022-06-20 10:23:37 +08:00
|
|
|
AND type = #{type}
|
2022-06-19 17:14:53 +08:00
|
|
|
</if>
|
2022-04-27 16:50:16 +08:00
|
|
|
GROUP BY type
|
|
|
|
ORDER BY type
|
2022-04-14 23:51:01 +08:00
|
|
|
</select>
|
2022-04-23 18:51:52 +08:00
|
|
|
|
|
|
|
<select id="selectMostPopular" resultType="io.renren.modules.resource.dto.ResourceDTO">
|
|
|
|
SELECT
|
2022-06-27 19:42:02 +08:00
|
|
|
tdr.id,
|
|
|
|
tdr.`type`,
|
|
|
|
tdr.`name`,
|
|
|
|
tdr.description,
|
|
|
|
tdr.link,
|
|
|
|
tdr.api_method_type,
|
|
|
|
tdr.api_url,
|
|
|
|
tdr.group_id,
|
|
|
|
tdr.dept_id,
|
|
|
|
tdr.dept_contacts,
|
|
|
|
tdr.dept_phone,
|
|
|
|
tdr.share_type,
|
|
|
|
tdr.share_mode,
|
|
|
|
tdr.share_condition,
|
|
|
|
tdr.district_id,
|
|
|
|
tdr.visits,
|
|
|
|
tdr.del_flag,
|
|
|
|
tdr.creator,
|
|
|
|
tdr.create_date,
|
|
|
|
tdr.updater,
|
|
|
|
tdr.update_date,
|
|
|
|
tdr.note1,
|
|
|
|
tdr.note2,
|
|
|
|
tdr.note3,
|
|
|
|
tdr.note4,
|
|
|
|
tdr.note5,
|
|
|
|
tdr.enclosure,
|
|
|
|
tdr.undercarriage_reason,
|
|
|
|
tdr.undercarriage_user_name,
|
|
|
|
tdr.info_list,
|
2022-06-28 13:40:59 +08:00
|
|
|
tdr.total AS total,
|
2022-05-18 16:13:51 +08:00
|
|
|
IFNULL(trs.score, 0 ) AS "score",
|
|
|
|
IFNULL(taa.applyCount, 0 ) AS "applyCount",
|
2022-06-28 13:40:59 +08:00
|
|
|
IFNULL(trc.collectCount, 0) AS "collectCount"
|
2022-06-28 17:48:29 +08:00
|
|
|
<!-- (IFNULL(visits / 100, 0) + IFNULL(trs.score, 0) + IFNULL(applyCount,0)+ IFNULL(collectCount,0)) AS total-->
|
2022-04-23 18:51:52 +08:00
|
|
|
FROM
|
2022-05-18 16:13:51 +08:00
|
|
|
tb_data_resource tdr
|
|
|
|
LEFT JOIN ( SELECT resource_id, SUM(score) AS "score" FROM tb_resource_score WHERE 1 = 1 AND del_flag = 0 GROUP
|
|
|
|
BY resource_id ) trs ON tdr.id = trs.resource_id
|
|
|
|
LEFT JOIN ( SELECT resource_id, COUNT(id) AS "applyCount" FROM t_ability_application WHERE 1 = 1 AND del_flag =
|
|
|
|
0 GROUP BY resource_id ) taa ON tdr.id = taa.resource_id
|
|
|
|
LEFT JOIN ( SELECT resource_id, COUNT(id) AS "collectCount" FROM tb_resource_collection WHERE 1 = 1 AND del_flag
|
|
|
|
= 0 GROUP BY resource_id ) trc ON tdr.id = trc.resource_id
|
2022-04-23 18:51:52 +08:00
|
|
|
WHERE
|
2022-05-18 16:13:51 +08:00
|
|
|
1 = 1
|
|
|
|
AND tdr.del_flag = 0
|
|
|
|
<if test="type != null and type != ''">
|
2022-06-27 15:44:18 +08:00
|
|
|
<!-- AND tdr.type LIKE CONCAT('%',#{type},'%') -->
|
|
|
|
AND MATCH (tdr.type) AGAINST ( #{type} IN BOOLEAN MODE)
|
2022-05-18 16:13:51 +08:00
|
|
|
</if>
|
|
|
|
<if test="name != null and name != ''">
|
2022-06-27 15:44:18 +08:00
|
|
|
<!--AND tdr.name LIKE CONCAT('%',#{name},'%') -->
|
|
|
|
AND MATCH (tdr.name) AGAINST ( #{name} IN BOOLEAN MODE)
|
2022-05-18 16:13:51 +08:00
|
|
|
</if>
|
2022-04-25 14:08:34 +08:00
|
|
|
ORDER BY ${orderFiled} ${orderType}
|
|
|
|
LIMIT ${pageNum}, ${pageSize}
|
2022-04-23 18:51:52 +08:00
|
|
|
</select>
|
2022-04-27 16:50:16 +08:00
|
|
|
|
2022-04-27 18:05:47 +08:00
|
|
|
<select id="selectDTOById" resultMap="resourceDTO">
|
2022-04-27 16:50:16 +08:00
|
|
|
SELECT
|
2022-06-27 19:42:02 +08:00
|
|
|
tdr.id,
|
|
|
|
tdr.`type`,
|
|
|
|
tdr.`name`,
|
|
|
|
tdr.description,
|
|
|
|
tdr.link,
|
|
|
|
tdr.api_method_type,
|
|
|
|
tdr.api_url,
|
|
|
|
tdr.group_id,
|
|
|
|
tdr.dept_id,
|
|
|
|
tdr.dept_contacts,
|
|
|
|
tdr.dept_phone,
|
|
|
|
tdr.share_type,
|
|
|
|
tdr.share_mode,
|
|
|
|
tdr.share_condition,
|
|
|
|
tdr.district_id,
|
|
|
|
tdr.visits,
|
|
|
|
tdr.del_flag,
|
|
|
|
tdr.creator,
|
|
|
|
tdr.create_date,
|
|
|
|
tdr.updater,
|
|
|
|
tdr.update_date,
|
|
|
|
tdr.note1,
|
|
|
|
tdr.note2,
|
|
|
|
tdr.note3,
|
|
|
|
tdr.note4,
|
|
|
|
tdr.note5,
|
|
|
|
tdr.enclosure,
|
|
|
|
tdr.undercarriage_reason,
|
|
|
|
tdr.undercarriage_user_name,
|
|
|
|
tdr.info_list,
|
2022-06-03 10:55:59 +08:00
|
|
|
IFNULL( trs.score, 0 ) AS "score",
|
|
|
|
IFNULL( taa.applyCount, 0 ) AS "applyCount",
|
|
|
|
IFNULL( trc.collectCount, 0 ) AS "collectCount",
|
|
|
|
sd.NAME AS "deptName",
|
|
|
|
IFNULL( trc2.isCollect, 'false' ) AS "isCollect",
|
|
|
|
IF
|
2022-06-19 17:14:53 +08:00
|
|
|
( taa2.approve_status < 1, '未申请', '已申请' ) AS "applyState"
|
2022-04-27 16:50:16 +08:00
|
|
|
FROM
|
2022-05-18 16:13:51 +08:00
|
|
|
tb_data_resource tdr
|
2022-06-13 17:11:58 +08:00
|
|
|
LEFT JOIN ( SELECT resource_id, AVG( score ) AS "score" FROM tb_resource_score WHERE 1 = 1 AND del_flag = 0
|
|
|
|
GROUP BY resource_id ) trs ON tdr.id = trs.resource_id
|
|
|
|
LEFT JOIN ( SELECT resource_id, COUNT( id ) AS "applyCount" FROM t_ability_application WHERE 1 = 1 AND del_flag
|
|
|
|
= 0 GROUP BY resource_id ) taa ON tdr.id = taa.resource_id
|
|
|
|
LEFT JOIN ( SELECT resource_id, COUNT( id ) AS "collectCount" FROM tb_resource_collection WHERE 1 = 1 AND
|
|
|
|
del_flag = 0 GROUP BY resource_id ) trc ON tdr.id = trc.resource_id
|
2022-06-03 10:55:59 +08:00
|
|
|
LEFT JOIN (
|
|
|
|
SELECT
|
|
|
|
resource_id,
|
|
|
|
user_id,
|
2022-06-13 17:11:58 +08:00
|
|
|
( IF(COUNT( id ) = 1, 'true', 'false') ) AS "isCollect"
|
2022-06-03 10:55:59 +08:00
|
|
|
FROM
|
|
|
|
tb_resource_collection
|
|
|
|
WHERE
|
|
|
|
1 = 1
|
|
|
|
AND del_flag = 0
|
|
|
|
AND user_id = #{userId}
|
|
|
|
GROUP BY
|
|
|
|
resource_id
|
|
|
|
) trc2 ON tdr.id = trc2.resource_id
|
2022-06-13 17:11:58 +08:00
|
|
|
LEFT JOIN ( SELECT resource_id, COUNT( approve_status ) approve_status FROM t_ability_application WHERE 1 = 1
|
|
|
|
AND del_flag = 0 AND user_id = #{userId} GROUP BY resource_id ) taa2 ON tdr.id = taa2.resource_id
|
2022-05-18 16:13:51 +08:00
|
|
|
LEFT JOIN sys_dept sd ON tdr.dept_id = sd.id
|
2022-06-03 10:55:59 +08:00
|
|
|
WHERE
|
|
|
|
1 = 1
|
2022-05-11 15:31:48 +08:00
|
|
|
AND tdr.id = #{id}
|
2022-04-27 16:50:16 +08:00
|
|
|
</select>
|
|
|
|
|
2022-06-30 10:56:11 +08:00
|
|
|
<select id="selectDTOPage" resultMap="resourceDTO">
|
2022-04-27 16:50:16 +08:00
|
|
|
SELECT
|
2022-06-27 19:42:02 +08:00
|
|
|
tdr.id,
|
|
|
|
tdr.`type`,
|
|
|
|
tdr.`name`,
|
|
|
|
tdr.description,
|
|
|
|
tdr.link,
|
|
|
|
tdr.api_method_type,
|
|
|
|
tdr.api_url,
|
|
|
|
tdr.group_id,
|
|
|
|
tdr.dept_id,
|
|
|
|
tdr.dept_contacts,
|
|
|
|
tdr.dept_phone,
|
|
|
|
tdr.share_type,
|
|
|
|
tdr.share_mode,
|
|
|
|
tdr.share_condition,
|
|
|
|
tdr.district_id,
|
|
|
|
tdr.visits,
|
|
|
|
tdr.del_flag,
|
|
|
|
tdr.creator,
|
|
|
|
tdr.create_date,
|
|
|
|
tdr.updater,
|
|
|
|
tdr.update_date,
|
|
|
|
tdr.note1,
|
|
|
|
tdr.note2,
|
|
|
|
tdr.note3,
|
|
|
|
tdr.note4,
|
|
|
|
tdr.note5,
|
|
|
|
tdr.enclosure,
|
|
|
|
tdr.undercarriage_reason,
|
|
|
|
tdr.undercarriage_user_name,
|
2022-06-30 10:56:11 +08:00
|
|
|
tdr.info_list,
|
2022-06-28 13:40:59 +08:00
|
|
|
tdr.total AS total,
|
2022-05-18 16:13:51 +08:00
|
|
|
IFNULL(trs.score, 0 ) AS "score",
|
|
|
|
IFNULL(taa.applyCount, 0 ) AS "applyCount",
|
|
|
|
IFNULL(trc.collectCount, 0) AS "collectCount",
|
|
|
|
sd.name AS "deptName",
|
|
|
|
IFNULL(trc2.isCollect, 'false') AS "isCollect",
|
2022-06-28 13:40:59 +08:00
|
|
|
IFNULL(taa2.approve_status, '未申请') AS "applyState"
|
2022-04-27 16:50:16 +08:00
|
|
|
FROM
|
2022-05-18 16:13:51 +08:00
|
|
|
tb_data_resource tdr
|
|
|
|
LEFT JOIN ( SELECT resource_id, AVG(score) AS "score" FROM tb_resource_score WHERE 1 = 1 AND del_flag = 0 GROUP
|
|
|
|
BY resource_id ) trs ON tdr.id = trs.resource_id
|
|
|
|
LEFT JOIN ( SELECT resource_id, COUNT(id) AS "applyCount" FROM t_ability_application WHERE 1 = 1 AND del_flag =
|
|
|
|
0 GROUP BY resource_id ) taa ON tdr.id = taa.resource_id
|
|
|
|
LEFT JOIN ( SELECT resource_id, COUNT(id) AS "collectCount" FROM tb_resource_collection WHERE 1 = 1 AND del_flag
|
|
|
|
= 0 GROUP BY resource_id ) trc ON tdr.id = trc.resource_id
|
2022-06-13 17:11:58 +08:00
|
|
|
LEFT JOIN ( SELECT resource_id, user_id, ( IF(COUNT( id ) = 1, 'true', 'false') ) AS "isCollect"
|
2022-06-02 16:55:00 +08:00
|
|
|
FROM tb_resource_collection WHERE 1 = 1 AND del_flag = 0 AND user_id = #{dto.creator}
|
2022-05-18 16:13:51 +08:00
|
|
|
GROUP BY resource_id) trc2 ON tdr.id = trc2.resource_id
|
2022-06-13 17:11:58 +08:00
|
|
|
LEFT JOIN ( SELECT DISTINCT resource_id, approve_status FROM t_ability_application WHERE 1 = 1 AND del_flag = 0
|
|
|
|
AND user_id = #{dto.creator}
|
2022-05-18 16:13:51 +08:00
|
|
|
GROUP BY id) taa2 ON tdr.id = taa2.resource_id
|
|
|
|
LEFT JOIN sys_dept sd ON tdr.dept_id = sd.id
|
2022-04-27 16:50:16 +08:00
|
|
|
WHERE 1 = 1
|
2022-05-18 16:13:51 +08:00
|
|
|
AND tdr.del_flag = 0
|
|
|
|
<if test="dto.name != null and dto.name != ''">
|
2022-06-27 15:44:18 +08:00
|
|
|
AND MATCH (tdr.name) AGAINST ( #{dto.name} IN BOOLEAN MODE)
|
2022-04-27 16:50:16 +08:00
|
|
|
</if>
|
2022-05-18 16:13:51 +08:00
|
|
|
<if test="dto.type != null and dto.type != ''">
|
2022-04-27 16:50:16 +08:00
|
|
|
AND tdr.type = #{dto.type}
|
|
|
|
</if>
|
2022-05-18 16:13:51 +08:00
|
|
|
<if test="dto.districtId != null and dto.districtId != ''">
|
2022-04-27 16:50:16 +08:00
|
|
|
AND tdr.district_id = #{dto.districtId}
|
|
|
|
</if>
|
2022-05-19 17:22:53 +08:00
|
|
|
<if test="null != dto.deptIds and dto.deptIds.size > 0">
|
2022-05-20 11:30:29 +08:00
|
|
|
AND tdr.dept_id IN
|
|
|
|
<foreach collection="dto.deptIds" item="item" open="(" separator="," close=")">
|
2022-05-19 17:22:53 +08:00
|
|
|
#{item}
|
2022-05-20 11:30:29 +08:00
|
|
|
</foreach>
|
2022-05-19 17:22:53 +08:00
|
|
|
</if>
|
2022-05-18 16:13:51 +08:00
|
|
|
<if test="dto.shareCondition != null and dto.shareCondition != ''">
|
2022-05-13 17:30:05 +08:00
|
|
|
AND tdr.share_condition = #{dto.shareCondition}
|
|
|
|
</if>
|
2022-05-18 16:13:51 +08:00
|
|
|
<if test="dto.deptId != null and dto.deptId != ''">
|
2022-05-11 20:19:31 +08:00
|
|
|
AND tdr.dept_id = #{dto.deptId}
|
|
|
|
</if>
|
2022-06-28 17:48:29 +08:00
|
|
|
<if test="ids != null and ids.size > 0">
|
|
|
|
AND tdr.id IN
|
|
|
|
<foreach collection="ids" item="item_" open="(" separator="," close=")">
|
|
|
|
#{item_}
|
|
|
|
</foreach>
|
|
|
|
</if>
|
|
|
|
<if test="orderField != null and orderField !=''">
|
|
|
|
ORDER BY ${orderField} ${orderType}
|
|
|
|
LIMIT ${pageNum}, ${pageSize}
|
|
|
|
</if>
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<select id="selectDTOPageSpecilTotal" resultType="java.util.Map">
|
|
|
|
SELECT
|
|
|
|
tdr.id,
|
|
|
|
tdr.total AS total
|
|
|
|
FROM
|
|
|
|
tb_data_resource tdr
|
|
|
|
WHERE
|
|
|
|
1 = 1
|
|
|
|
<if test="dto.name != null and dto.name != ''">
|
|
|
|
AND MATCH (tdr.name) AGAINST ( #{dto.name} IN BOOLEAN MODE)
|
|
|
|
</if>
|
|
|
|
<if test="dto.type != null and dto.type != ''">
|
|
|
|
AND tdr.type = #{dto.type}
|
|
|
|
</if>
|
|
|
|
<if test="dto.districtId != null and dto.districtId != ''">
|
|
|
|
AND tdr.district_id = #{dto.districtId}
|
|
|
|
</if>
|
|
|
|
<if test="null != dto.deptIds and dto.deptIds.size > 0">
|
|
|
|
AND tdr.dept_id IN
|
|
|
|
<foreach collection="dto.deptIds" item="item" open="(" separator="," close=")">
|
|
|
|
#{item}
|
|
|
|
</foreach>
|
|
|
|
</if>
|
|
|
|
<if test="dto.shareCondition != null and dto.shareCondition != ''">
|
|
|
|
AND tdr.share_condition = #{dto.shareCondition}
|
|
|
|
</if>
|
|
|
|
<if test="dto.deptId != null and dto.deptId != ''">
|
|
|
|
AND tdr.dept_id = #{dto.deptId}
|
|
|
|
</if>
|
2022-04-27 16:50:16 +08:00
|
|
|
</select>
|
2022-06-28 17:48:29 +08:00
|
|
|
|
2022-06-27 19:58:24 +08:00
|
|
|
<select id="selectDTOPageCount" resultType="java.lang.Long">
|
|
|
|
SELECT
|
2022-06-28 17:48:29 +08:00
|
|
|
COUNT(DISTINCT tdr.id)
|
2022-06-27 19:58:24 +08:00
|
|
|
FROM
|
2022-06-28 17:48:29 +08:00
|
|
|
tb_data_resource tdr
|
2022-06-27 19:58:24 +08:00
|
|
|
WHERE
|
2022-06-28 17:48:29 +08:00
|
|
|
1 = 1
|
|
|
|
AND tdr.del_flag = 0
|
2022-06-27 19:58:24 +08:00
|
|
|
<if test="dto.name != null and dto.name != ''">
|
|
|
|
AND MATCH (tdr.name) AGAINST ( #{dto.name} IN BOOLEAN MODE)
|
|
|
|
<!--AND tdr.name LIKE CONCAT('%',#{dto.name},'%') -->
|
|
|
|
</if>
|
|
|
|
<if test="dto.type != null and dto.type != ''">
|
|
|
|
AND tdr.type = #{dto.type}
|
|
|
|
</if>
|
|
|
|
<if test="dto.districtId != null and dto.districtId != ''">
|
|
|
|
AND tdr.district_id = #{dto.districtId}
|
|
|
|
</if>
|
|
|
|
<if test="null != dto.deptIds and dto.deptIds.size > 0">
|
|
|
|
AND tdr.dept_id IN
|
|
|
|
<foreach collection="dto.deptIds" item="item" open="(" separator="," close=")">
|
|
|
|
#{item}
|
|
|
|
</foreach>
|
|
|
|
</if>
|
|
|
|
<if test="dto.shareCondition != null and dto.shareCondition != ''">
|
|
|
|
AND tdr.share_condition = #{dto.shareCondition}
|
|
|
|
</if>
|
|
|
|
<if test="dto.deptId != null and dto.deptId != ''">
|
|
|
|
AND tdr.dept_id = #{dto.deptId}
|
|
|
|
</if>
|
|
|
|
</select>
|
2022-04-28 20:19:09 +08:00
|
|
|
|
|
|
|
<select id="selectApplyArea" resultType="java.util.Map">
|
|
|
|
SELECT
|
2022-05-11 15:31:48 +08:00
|
|
|
*
|
2022-04-28 20:19:09 +08:00
|
|
|
FROM
|
2022-05-11 15:31:48 +08:00
|
|
|
(
|
|
|
|
SELECT
|
|
|
|
attr_value,
|
|
|
|
IFNULL( COUNT( trc.id ), 0 ) AS "colCount",
|
|
|
|
IFNULL( COUNT( taa.id ), 0 ) AS "aplCount",
|
|
|
|
(
|
|
|
|
IFNULL( COUNT( trc.id ), 0 ) + IFNULL( COUNT( taa.id ), 0 )) AS total
|
|
|
|
FROM
|
|
|
|
tb_data_attr tda
|
|
|
|
LEFT JOIN tb_resource_collection trc ON tda.data_resource_id = trc.resource_id
|
|
|
|
AND trc.del_flag = 0
|
|
|
|
AND trc.user_id = #{userId}
|
|
|
|
LEFT JOIN t_ability_application taa ON tda.data_resource_id = taa.resource_id
|
|
|
|
AND taa.del_flag = 0
|
|
|
|
AND taa.user_id = #{userId}
|
2022-04-28 20:19:09 +08:00
|
|
|
WHERE
|
2022-05-11 15:31:48 +08:00
|
|
|
1 = 1
|
|
|
|
AND tda.attr_type = '应用领域'
|
|
|
|
AND tda.del_flag = 0
|
|
|
|
AND ( attr_value != '' AND attr_value IS NOT NULL )
|
|
|
|
GROUP BY
|
|
|
|
attr_value
|
|
|
|
ORDER BY
|
|
|
|
total DESC
|
|
|
|
) temp
|
|
|
|
WHERE
|
|
|
|
temp.total != 0
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<select id="getAmountGroupByType" resultType="java.util.Map">
|
|
|
|
SELECT
|
|
|
|
COUNT( id ) AS amount,
|
|
|
|
type AS type
|
|
|
|
FROM
|
|
|
|
tb_data_resource
|
|
|
|
WHERE
|
|
|
|
del_flag = 0
|
|
|
|
GROUP BY
|
|
|
|
type
|
2022-04-28 20:19:09 +08:00
|
|
|
</select>
|
2022-06-02 16:55:00 +08:00
|
|
|
|
2022-05-11 17:25:21 +08:00
|
|
|
<select id="countAllDept" resultType="java.lang.Long">
|
|
|
|
SELECT
|
|
|
|
COUNT( DISTINCT dept_id )
|
|
|
|
FROM
|
|
|
|
tb_data_resource
|
|
|
|
WHERE
|
|
|
|
del_flag = 0
|
|
|
|
</select>
|
2022-05-11 20:19:31 +08:00
|
|
|
|
|
|
|
<select id="selectGroupByDeptId" resultType="java.util.Map">
|
|
|
|
SELECT
|
2022-05-18 16:13:51 +08:00
|
|
|
*
|
|
|
|
FROM
|
|
|
|
(
|
|
|
|
SELECT
|
|
|
|
( CASE sd.type WHEN 1 THEN '省级' WHEN 2 THEN '市级' WHEN 3 THEN '区级' WHEN 4 THEN '企业' ELSE '其他' END ) AS "type",
|
|
|
|
sd.NAME AS "deptName",
|
|
|
|
IFNULL( tdr.deptCount, 0 ) AS "deptCount",
|
2022-05-19 15:07:23 +08:00
|
|
|
sd.id AS "deptId",
|
2022-05-19 17:22:53 +08:00
|
|
|
sr.name AS "districtName",
|
|
|
|
sr.id AS "districtId"
|
2022-05-11 20:19:31 +08:00
|
|
|
FROM
|
2022-05-18 16:13:51 +08:00
|
|
|
sys_dept sd
|
2022-06-02 16:55:00 +08:00
|
|
|
LEFT JOIN ( SELECT dept_id, COUNT( id ) AS "deptCount" FROM tb_data_resource WHERE 1 = 1 AND del_flag = 0
|
2022-05-18 16:13:51 +08:00
|
|
|
<if test="type != null and type != ''">
|
|
|
|
AND type = #{type}
|
|
|
|
</if>
|
|
|
|
GROUP BY dept_id ) tdr ON sd.id = tdr.dept_id
|
2022-05-19 15:07:23 +08:00
|
|
|
LEFT JOIN sys_region sr ON sd.district = sr.id
|
2022-05-18 16:13:51 +08:00
|
|
|
) temp1
|
2022-05-11 20:19:31 +08:00
|
|
|
WHERE
|
2022-05-18 16:13:51 +08:00
|
|
|
1 = 1
|
|
|
|
AND temp1.deptCount != 0
|
2022-05-11 20:19:31 +08:00
|
|
|
</select>
|
|
|
|
|
|
|
|
<select id="selectTypeCountByDept" resultType="java.lang.Integer">
|
|
|
|
SELECT
|
2022-05-18 16:13:51 +08:00
|
|
|
SUM( deptCount )
|
2022-05-11 20:19:31 +08:00
|
|
|
FROM
|
2022-05-18 16:13:51 +08:00
|
|
|
(
|
|
|
|
SELECT
|
2022-06-13 17:11:58 +08:00
|
|
|
type,
|
|
|
|
deptCount
|
2022-05-18 16:13:51 +08:00
|
|
|
FROM
|
|
|
|
(
|
|
|
|
SELECT
|
|
|
|
( CASE sd.type WHEN 1 THEN '省级' WHEN 2 THEN '市级' WHEN 3 THEN '区级' WHEN 4 THEN '企业' ELSE '其他' END ) AS "type",
|
|
|
|
IFNULL( tdr.deptCount, 0 ) AS "deptCount"
|
|
|
|
FROM
|
|
|
|
sys_dept sd
|
2022-06-02 16:55:00 +08:00
|
|
|
LEFT JOIN ( SELECT dept_id, COUNT( id ) AS "deptCount" FROM tb_data_resource WHERE 1 = 1 AND del_flag = 0
|
2022-05-18 16:13:51 +08:00
|
|
|
<if test="resourceType != null and resourceType != ''">
|
|
|
|
AND type = #{resourceType}
|
|
|
|
</if>
|
|
|
|
GROUP BY dept_id ) tdr ON sd.id = tdr.dept_id
|
|
|
|
) temp1
|
|
|
|
WHERE
|
|
|
|
1 = 1
|
|
|
|
AND temp1.deptCount != 0
|
|
|
|
) temp2
|
|
|
|
WHERE 1 = 1
|
|
|
|
AND temp2.type = #{deptType}
|
2022-05-11 20:19:31 +08:00
|
|
|
GROUP BY
|
2022-05-18 16:13:51 +08:00
|
|
|
temp2.type
|
2022-05-11 20:19:31 +08:00
|
|
|
</select>
|
2022-05-17 18:13:13 +08:00
|
|
|
|
|
|
|
<select id="selectAlgorithmPage" resultType="io.renren.modules.resource.dto.ResourceDTO">
|
|
|
|
SELECT *
|
|
|
|
FROM tb_data_resource
|
|
|
|
WHERE 1 = 1
|
|
|
|
ORDER BY ${orderField} ${orderType}
|
|
|
|
LIMIT ${pageNum}, ${pageSize}
|
|
|
|
</select>
|
|
|
|
|
2022-05-19 15:07:23 +08:00
|
|
|
<select id="selectTypeCountByDist" resultType="java.lang.Integer">
|
|
|
|
SELECT
|
|
|
|
SUM( deptCount )
|
|
|
|
FROM
|
|
|
|
(
|
|
|
|
SELECT
|
2022-06-13 17:11:58 +08:00
|
|
|
type, deptCount, districtName
|
2022-05-19 15:07:23 +08:00
|
|
|
FROM
|
|
|
|
(
|
|
|
|
SELECT
|
|
|
|
( CASE sd.type WHEN 1 THEN '省级' WHEN 2 THEN '市级' WHEN 3 THEN '区级' WHEN 4 THEN '企业' ELSE '其他' END ) AS "type",
|
|
|
|
IFNULL( tdr.deptCount, 0) AS "deptCount",
|
2022-06-14 09:32:40 +08:00
|
|
|
IFNULL(sr.name, '暂无该地区') AS "districtName"
|
2022-05-19 15:07:23 +08:00
|
|
|
FROM
|
|
|
|
sys_dept sd
|
|
|
|
LEFT JOIN ( SELECT dept_id, COUNT( id ) AS "deptCount" FROM tb_data_resource
|
2022-06-02 16:55:00 +08:00
|
|
|
WHERE 1 = 1 AND del_flag = 0
|
2022-05-19 15:07:23 +08:00
|
|
|
<if test="resourceType != null and resourceType != ''">
|
|
|
|
AND type = #{resourceType}
|
|
|
|
</if>
|
|
|
|
GROUP BY dept_id ) tdr ON sd.id = tdr.dept_id
|
|
|
|
LEFT JOIN sys_region sr ON sd.district = sr.id
|
|
|
|
) temp1
|
|
|
|
WHERE
|
|
|
|
1 = 1
|
|
|
|
AND temp1.deptCount != 0
|
|
|
|
) temp2
|
|
|
|
WHERE 1 = 1
|
|
|
|
AND temp2.districtName = #{districtName}
|
|
|
|
GROUP BY
|
|
|
|
temp2.type
|
|
|
|
</select>
|
2022-06-02 16:55:00 +08:00
|
|
|
|
2022-05-20 11:30:29 +08:00
|
|
|
<select id="countAllVisits" resultType="java.lang.Long">
|
|
|
|
SELECT
|
2022-06-02 16:55:00 +08:00
|
|
|
SUM( visits )
|
2022-05-20 11:30:29 +08:00
|
|
|
FROM
|
|
|
|
tb_data_resource
|
|
|
|
</select>
|
2022-05-19 15:07:23 +08:00
|
|
|
|
2022-05-23 18:28:02 +08:00
|
|
|
<select id="selectDeptCount" resultType="java.lang.Integer">
|
|
|
|
SELECT
|
2022-05-24 18:01:31 +08:00
|
|
|
COUNT( 1 )
|
2022-05-23 18:28:02 +08:00
|
|
|
FROM
|
2022-05-24 18:01:31 +08:00
|
|
|
( SELECT DISTINCT dept_id FROM tb_data_resource WHERE 1 = 1 AND del_flag = 0 AND dept_id IS NOT NULL ) temp
|
2022-05-23 18:28:02 +08:00
|
|
|
</select>
|
|
|
|
|
|
|
|
<select id="selectDeptTypeCount" resultType="java.util.Map">
|
|
|
|
SELECT IFNULL(COUNT(deptId),0) AS "count",
|
2022-05-24 18:01:31 +08:00
|
|
|
type
|
2022-05-23 18:28:02 +08:00
|
|
|
FROM (
|
2022-05-24 18:01:31 +08:00
|
|
|
SELECT DISTINCT
|
|
|
|
tbr.dept_id AS "deptId",
|
|
|
|
(CASE sd.type
|
|
|
|
WHEN 1 THEN
|
|
|
|
'省级'
|
|
|
|
WHEN 2 THEN
|
|
|
|
'市级'
|
|
|
|
WHEN 3 THEN
|
|
|
|
'区级'
|
|
|
|
WHEN 4 THEN
|
|
|
|
'企业' ELSE '其他'
|
|
|
|
END ) AS "type"
|
2022-05-23 18:28:02 +08:00
|
|
|
FROM
|
2022-05-24 18:01:31 +08:00
|
|
|
sys_dept sd
|
|
|
|
RIGHT JOIN tb_data_resource tbr ON tbr.dept_id = sd.id
|
2022-05-23 18:28:02 +08:00
|
|
|
WHERE
|
2022-05-24 18:01:31 +08:00
|
|
|
1 = 1
|
2022-05-23 18:28:02 +08:00
|
|
|
AND del_flag = 0
|
|
|
|
AND dept_id IS NOT NULL) temp GROUP BY type
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<select id="selectDeptTotalCount" resultType="java.util.Map">
|
|
|
|
SELECT
|
|
|
|
COUNT( type ) AS "total",
|
|
|
|
type
|
|
|
|
FROM
|
|
|
|
(
|
|
|
|
SELECT
|
|
|
|
(
|
|
|
|
CASE
|
2022-05-24 18:01:31 +08:00
|
|
|
WHEN ( COUNT( id ) BETWEEN 0 AND 5 ) THEN
|
|
|
|
'0'
|
|
|
|
WHEN ( COUNT( id ) BETWEEN 5 AND 10 ) THEN
|
|
|
|
'5'
|
|
|
|
WHEN ( COUNT( id ) BETWEEN 10 AND 15 ) THEN
|
|
|
|
'10'
|
|
|
|
WHEN ( COUNT( id ) BETWEEN 15 AND 20 ) THEN
|
|
|
|
'15' ELSE '20'
|
2022-05-23 18:28:02 +08:00
|
|
|
END
|
|
|
|
) AS "type"
|
|
|
|
FROM
|
|
|
|
tb_data_resource
|
|
|
|
WHERE
|
|
|
|
del_flag = 0
|
|
|
|
AND dept_id IS NOT NULL
|
|
|
|
GROUP BY
|
|
|
|
dept_id
|
|
|
|
) temp
|
|
|
|
GROUP BY
|
|
|
|
type
|
|
|
|
</select>
|
2022-05-24 18:01:31 +08:00
|
|
|
<select id="selectDeptProvideCount" resultType="java.util.Map">
|
|
|
|
SELECT
|
2022-05-25 09:44:09 +08:00
|
|
|
COUNT( DISTINCT temp.value_ ) count,
|
2022-05-24 18:01:31 +08:00
|
|
|
any_value ( tdr.dept_id ) dept_id
|
|
|
|
FROM
|
2022-05-25 09:44:09 +08:00
|
|
|
(
|
|
|
|
SELECT
|
|
|
|
SUBSTRING_INDEX( SUBSTRING_INDEX( tdav.attr_value, ';', b.help_topic_id + 1 ), ';',- 1 ) AS value_,
|
|
|
|
tdav.data_resource_id AS resourceId
|
|
|
|
FROM
|
|
|
|
tb_data_attr tdav
|
2022-06-20 10:23:37 +08:00
|
|
|
JOIN mysql.help_topic b ON b.help_topic_id < ( LENGTH( tdav.attr_value ) - LENGTH( REPLACE ( tdav.attr_value,
|
|
|
|
';', '' ) ) + 1 )
|
2022-05-24 18:01:31 +08:00
|
|
|
WHERE
|
2022-05-25 09:44:09 +08:00
|
|
|
1 = 1
|
|
|
|
AND tdav.attr_type = '应用领域'
|
|
|
|
AND tdav.del_flag = 0
|
|
|
|
) temp
|
|
|
|
INNER JOIN tb_data_resource tdr ON temp.resourceId = tdr.id
|
|
|
|
AND tdr.dept_id IS NOT NULL
|
2022-05-24 18:01:31 +08:00
|
|
|
GROUP BY
|
|
|
|
tdr.dept_id
|
|
|
|
ORDER BY
|
|
|
|
count DESC
|
|
|
|
LIMIT #{n}
|
|
|
|
</select>
|
|
|
|
<select id="selectDeptProvide" resultType="java.lang.String">
|
|
|
|
SELECT DISTINCT
|
|
|
|
tda.attr_value
|
|
|
|
FROM
|
|
|
|
tb_data_attr tda
|
|
|
|
INNER JOIN tb_data_resource tdr ON tda.data_resource_id = tdr.id
|
|
|
|
AND tdr.dept_id = #{deptId}
|
|
|
|
WHERE
|
|
|
|
tda.attr_type = '应用领域'
|
|
|
|
</select>
|
2022-05-23 18:28:02 +08:00
|
|
|
|
2022-05-24 19:49:37 +08:00
|
|
|
<select id="selectMaxDeptIds" resultType="java.lang.Long">
|
|
|
|
SELECT
|
2022-06-20 10:23:37 +08:00
|
|
|
dept_id
|
|
|
|
FROM
|
|
|
|
(
|
|
|
|
SELECT
|
|
|
|
COUNT( id ) AS "count",
|
|
|
|
dept_id
|
|
|
|
FROM
|
|
|
|
tb_data_resource
|
|
|
|
WHERE
|
|
|
|
1 = 1
|
|
|
|
AND del_flag = 0
|
|
|
|
AND dept_id IS NOT NULL
|
|
|
|
GROUP BY
|
|
|
|
dept_id
|
|
|
|
) temp1
|
|
|
|
WHERE
|
|
|
|
temp1.count = (
|
|
|
|
SELECT
|
|
|
|
MAX( count ) AS "total"
|
|
|
|
FROM
|
|
|
|
(
|
|
|
|
SELECT
|
|
|
|
COUNT( id ) AS "count"
|
|
|
|
FROM
|
|
|
|
tb_data_resource
|
|
|
|
WHERE
|
|
|
|
1 = 1
|
|
|
|
AND del_flag = 0
|
|
|
|
AND dept_id IS NOT NULL
|
|
|
|
GROUP BY
|
|
|
|
dept_id
|
|
|
|
) temp2
|
|
|
|
)
|
2022-05-24 19:49:37 +08:00
|
|
|
</select>
|
|
|
|
|
|
|
|
<select id="selectByDeptId" resultType="java.util.Map">
|
|
|
|
SELECT id,
|
2022-06-20 10:23:37 +08:00
|
|
|
name
|
2022-05-24 19:49:37 +08:00
|
|
|
FROM tb_data_resource
|
|
|
|
WHERE 1 = 1
|
2022-06-20 10:23:37 +08:00
|
|
|
AND del_flag = 0
|
|
|
|
AND dept_id = #{deptId}
|
2022-05-24 19:49:37 +08:00
|
|
|
</select>
|
|
|
|
|
|
|
|
<select id="selectDeptCountList" resultType="java.util.Map">
|
|
|
|
SELECT
|
2022-06-20 10:23:37 +08:00
|
|
|
sd.id AS "deptId",
|
|
|
|
sd.NAME AS "deptName",
|
|
|
|
COUNT( tdr.id ) AS "total"
|
2022-05-24 19:49:37 +08:00
|
|
|
FROM
|
2022-06-20 10:23:37 +08:00
|
|
|
tb_data_resource tdr,
|
|
|
|
sys_dept sd
|
2022-05-24 19:49:37 +08:00
|
|
|
WHERE
|
2022-06-20 10:23:37 +08:00
|
|
|
1 = 1
|
|
|
|
AND tdr.del_flag = 0
|
|
|
|
AND tdr.dept_id = sd.id
|
2022-05-24 19:49:37 +08:00
|
|
|
GROUP BY tdr.dept_id
|
|
|
|
ORDER BY total DESC
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<select id="selectMaxApplyDeptIds" resultType="java.lang.Long">
|
|
|
|
SELECT
|
2022-06-20 10:23:37 +08:00
|
|
|
dept_id
|
|
|
|
FROM
|
|
|
|
(
|
|
|
|
SELECT
|
|
|
|
COUNT( taa.id ) AS "count",
|
|
|
|
su.dept_id
|
|
|
|
FROM
|
|
|
|
t_ability_application taa,
|
|
|
|
sys_user su
|
|
|
|
WHERE
|
|
|
|
1 = 1
|
|
|
|
AND taa.user_id = su.id
|
|
|
|
AND taa.user_id IS NOT NULL
|
|
|
|
GROUP BY
|
|
|
|
su.dept_id
|
|
|
|
) temp1
|
|
|
|
WHERE
|
|
|
|
temp1.count = (
|
|
|
|
SELECT
|
|
|
|
MAX( count ) AS "total"
|
|
|
|
FROM
|
|
|
|
(
|
|
|
|
SELECT
|
|
|
|
COUNT( taa.id ) AS "count"
|
|
|
|
FROM
|
|
|
|
t_ability_application taa,
|
|
|
|
sys_user su
|
|
|
|
WHERE
|
|
|
|
1 = 1
|
|
|
|
AND taa.user_id = su.id
|
|
|
|
AND taa.user_id IS NOT NULL
|
|
|
|
GROUP BY
|
|
|
|
su.dept_id
|
|
|
|
) temp2
|
|
|
|
)
|
2022-05-24 19:49:37 +08:00
|
|
|
</select>
|
|
|
|
|
|
|
|
<select id="selectByApplyDeptId" resultType="java.util.Map">
|
|
|
|
SELECT tdr.id,
|
2022-06-20 10:23:37 +08:00
|
|
|
tdr.name
|
2022-05-24 19:49:37 +08:00
|
|
|
FROM t_ability_application taa, tb_data_resource tdr, sys_user su
|
|
|
|
WHERE 1 = 1
|
2022-06-20 10:23:37 +08:00
|
|
|
AND tdr.del_flag = 0
|
|
|
|
AND su.id = taa.user_id
|
|
|
|
AND taa.resource_id = tdr.id
|
|
|
|
AND su.dept_id = #{deptId}
|
2022-05-24 19:49:37 +08:00
|
|
|
</select>
|
|
|
|
|
|
|
|
<select id="selectApplyDeptCountList" resultType="java.util.Map">
|
|
|
|
SELECT
|
2022-06-20 10:23:37 +08:00
|
|
|
sd.id AS "deptId",
|
|
|
|
sd.NAME AS "deptName",
|
|
|
|
COUNT( taa.resource_id ) AS "total"
|
2022-05-24 19:49:37 +08:00
|
|
|
FROM
|
2022-06-20 10:23:37 +08:00
|
|
|
t_ability_application taa,
|
|
|
|
sys_user su,
|
|
|
|
sys_dept sd
|
2022-05-24 19:49:37 +08:00
|
|
|
WHERE
|
2022-06-20 10:23:37 +08:00
|
|
|
1 = 1
|
|
|
|
AND su.id = taa.user_id
|
|
|
|
AND su.dept_id = sd.id
|
2022-05-24 19:49:37 +08:00
|
|
|
GROUP BY
|
2022-06-20 10:23:37 +08:00
|
|
|
sd.id
|
2022-05-24 19:49:37 +08:00
|
|
|
ORDER BY
|
2022-06-20 10:23:37 +08:00
|
|
|
total DESC
|
2022-05-24 19:49:37 +08:00
|
|
|
</select>
|
|
|
|
|
|
|
|
<select id="selectDeptTypeCountList" resultType="java.util.Map">
|
|
|
|
SELECT
|
2022-06-20 10:23:37 +08:00
|
|
|
COUNT( tdr.id ) AS "count",
|
|
|
|
sd.NAME AS "deptName",
|
|
|
|
(CASE tdr.type
|
|
|
|
WHEN '应用资源' THEN 'yyzy'
|
|
|
|
WHEN '组件服务' THEN 'zjfw'
|
|
|
|
WHEN '基础设施' THEN 'jcss'
|
|
|
|
WHEN '知识库' THEN 'zsk'
|
|
|
|
WHEN '数据资源' THEN 'sjzy'
|
|
|
|
ELSE 'yyzy' END)AS "type"
|
|
|
|
FROM
|
|
|
|
tb_data_resource tdr,
|
|
|
|
sys_dept sd
|
|
|
|
WHERE
|
|
|
|
1 = 1
|
|
|
|
AND tdr.del_flag = 0
|
|
|
|
AND tdr.dept_id = sd.id
|
2022-05-24 19:49:37 +08:00
|
|
|
GROUP BY
|
2022-06-20 10:23:37 +08:00
|
|
|
tdr.dept_id,
|
|
|
|
tdr.type
|
2022-05-24 19:49:37 +08:00
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
<select id="selectApplyDeptTypeCountList" resultType="java.util.Map">
|
|
|
|
SELECT
|
2022-06-20 10:23:37 +08:00
|
|
|
COUNT( taa.resource_id ) AS "count",
|
|
|
|
sd.NAME AS "deptName",
|
|
|
|
(
|
|
|
|
CASE
|
|
|
|
tdr.type
|
|
|
|
WHEN '应用资源' THEN
|
|
|
|
'yyzy'
|
|
|
|
WHEN '组件服务' THEN
|
|
|
|
'zjfw'
|
|
|
|
WHEN '基础设施' THEN
|
|
|
|
'jcss'
|
|
|
|
WHEN '知识库' THEN
|
|
|
|
'zsk'
|
|
|
|
WHEN '数据资源' THEN
|
|
|
|
'sjzy' ELSE 'yyzy'
|
|
|
|
END
|
|
|
|
) AS "type"
|
|
|
|
FROM
|
|
|
|
tb_data_resource tdr,
|
|
|
|
sys_dept sd,
|
|
|
|
sys_user su,
|
|
|
|
t_ability_application taa
|
|
|
|
WHERE
|
|
|
|
1 = 1
|
|
|
|
AND tdr.del_flag = 0
|
|
|
|
AND taa.user_id = su.id
|
|
|
|
AND su.dept_id = sd.id
|
|
|
|
AND taa.resource_id = tdr.id
|
2022-05-24 19:49:37 +08:00
|
|
|
GROUP BY
|
2022-06-20 10:23:37 +08:00
|
|
|
sd.id,
|
|
|
|
tdr.type
|
2022-05-24 19:49:37 +08:00
|
|
|
</select>
|
|
|
|
|
|
|
|
<select id="selectMaxType" resultType="java.lang.String">
|
|
|
|
SELECT
|
2022-06-20 10:23:37 +08:00
|
|
|
type
|
2022-05-24 19:49:37 +08:00
|
|
|
FROM
|
2022-06-20 10:23:37 +08:00
|
|
|
( SELECT COUNT( id ) AS "count", type FROM tb_data_resource WHERE 1 = 1 AND del_flag = 0 GROUP BY type ) temp1
|
2022-05-24 19:49:37 +08:00
|
|
|
WHERE
|
2022-06-20 10:23:37 +08:00
|
|
|
temp1.count = (
|
|
|
|
SELECT
|
|
|
|
MAX( count ) AS "total"
|
|
|
|
FROM
|
|
|
|
( SELECT COUNT( id ) AS "count" FROM tb_data_resource WHERE 1 = 1 AND del_flag = 0 GROUP BY type ) temp2
|
|
|
|
)
|
2022-05-24 19:49:37 +08:00
|
|
|
</select>
|
|
|
|
|
|
|
|
<select id="selectByType" resultType="java.util.Map">
|
|
|
|
SELECT id,
|
2022-06-20 10:23:37 +08:00
|
|
|
name
|
2022-05-24 19:49:37 +08:00
|
|
|
FROM tb_data_resource
|
|
|
|
WHERE 1 = 1
|
2022-06-20 10:23:37 +08:00
|
|
|
AND del_flag = 0
|
|
|
|
AND type = #{type}
|
2022-05-24 19:49:37 +08:00
|
|
|
</select>
|
|
|
|
|
|
|
|
<select id="selectTypeCountList" resultType="java.util.Map">
|
|
|
|
SELECT
|
2022-06-20 10:23:37 +08:00
|
|
|
tdr.type,
|
|
|
|
COUNT( tdr.id ) AS "total"
|
2022-05-24 19:49:37 +08:00
|
|
|
FROM
|
2022-06-20 10:23:37 +08:00
|
|
|
tb_data_resource tdr
|
2022-05-24 19:49:37 +08:00
|
|
|
WHERE
|
2022-06-20 10:23:37 +08:00
|
|
|
1 = 1
|
|
|
|
AND tdr.del_flag = 0
|
2022-05-24 19:49:37 +08:00
|
|
|
GROUP BY
|
2022-06-20 10:23:37 +08:00
|
|
|
tdr.type
|
2022-05-24 19:49:37 +08:00
|
|
|
ORDER BY
|
2022-06-20 10:23:37 +08:00
|
|
|
total DESC
|
2022-05-24 19:49:37 +08:00
|
|
|
</select>
|
|
|
|
|
2022-05-25 11:13:25 +08:00
|
|
|
<select id="selectMaxAppArea" resultType="java.lang.String">
|
|
|
|
SELECT
|
|
|
|
type
|
|
|
|
FROM
|
|
|
|
(
|
|
|
|
SELECT
|
|
|
|
SUBSTRING_INDEX( SUBSTRING_INDEX( tdav.attr_value, ';', b.help_topic_id + 1 ), ';',- 1 ) AS "type",
|
|
|
|
COUNT( tdav.data_resource_id ) AS "count"
|
|
|
|
FROM
|
|
|
|
tb_data_attr tdav
|
2022-06-20 10:23:37 +08:00
|
|
|
JOIN mysql.help_topic b ON b.help_topic_id < ( LENGTH( tdav.attr_value ) - LENGTH( REPLACE ( tdav.attr_value,
|
|
|
|
';', '' ) ) + 1 )
|
2022-05-25 11:13:25 +08:00
|
|
|
WHERE
|
|
|
|
1 = 1
|
|
|
|
AND tdav.attr_type = '应用领域'
|
|
|
|
AND tdav.del_flag = 0
|
|
|
|
AND SUBSTRING_INDEX( SUBSTRING_INDEX( tdav.attr_value, ';', b.help_topic_id + 1 ), ';',- 1 ) != ''
|
|
|
|
GROUP BY
|
|
|
|
type
|
|
|
|
) temp1
|
|
|
|
WHERE
|
|
|
|
temp1.count = (
|
|
|
|
SELECT
|
|
|
|
MAX( count ) AS "total"
|
|
|
|
FROM
|
|
|
|
(
|
|
|
|
SELECT
|
|
|
|
SUBSTRING_INDEX( SUBSTRING_INDEX( tdav.attr_value, ';', b.help_topic_id + 1 ), ';',- 1 ) AS "type",
|
|
|
|
COUNT( tdav.data_resource_id ) AS "count"
|
|
|
|
FROM
|
|
|
|
tb_data_attr tdav
|
2022-06-20 10:23:37 +08:00
|
|
|
JOIN mysql.help_topic b ON b.help_topic_id < ( LENGTH( tdav.attr_value ) - LENGTH( REPLACE ( tdav.attr_value,
|
|
|
|
';', '' ) ) + 1 )
|
2022-05-25 11:13:25 +08:00
|
|
|
WHERE
|
|
|
|
1 = 1
|
|
|
|
AND tdav.attr_type = '应用领域'
|
|
|
|
AND tdav.del_flag = 0
|
|
|
|
AND SUBSTRING_INDEX( SUBSTRING_INDEX( tdav.attr_value, ';', b.help_topic_id + 1 ), ';',- 1 ) != ''
|
|
|
|
GROUP BY
|
|
|
|
type
|
|
|
|
) temp2
|
|
|
|
)
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<select id="selectByAppArea" resultType="java.util.Map">
|
|
|
|
SELECT
|
2022-06-20 10:23:37 +08:00
|
|
|
tdr.id,
|
|
|
|
tdr.name
|
2022-05-25 11:13:25 +08:00
|
|
|
FROM
|
2022-06-20 10:23:37 +08:00
|
|
|
tb_data_resource tdr,
|
|
|
|
tb_data_attr tda
|
2022-05-25 11:13:25 +08:00
|
|
|
WHERE
|
2022-06-20 10:23:37 +08:00
|
|
|
1 = 1
|
|
|
|
AND tdr.del_flag = 0
|
|
|
|
AND tda.del_flag = 0
|
|
|
|
AND tdr.id = tda.data_resource_id
|
2022-06-27 15:44:18 +08:00
|
|
|
AND MATCH (attr_value) AGAINST ( #{type} IN BOOLEAN MODE)
|
|
|
|
<!-- AND attr_value LIKE CONCAT('%', #{type}, '%') -->
|
2022-05-25 11:13:25 +08:00
|
|
|
</select>
|
|
|
|
|
|
|
|
<select id="selectAppAreaCountList" resultType="java.util.Map">
|
|
|
|
SELECT
|
|
|
|
SUBSTRING_INDEX( SUBSTRING_INDEX( tdav.attr_value, ';', b.help_topic_id + 1 ), ';',- 1 ) AS "type",
|
|
|
|
COUNT( tdav.data_resource_id ) AS "total"
|
|
|
|
FROM
|
|
|
|
tb_data_attr tdav
|
2022-06-20 10:23:37 +08:00
|
|
|
JOIN mysql.help_topic b ON b.help_topic_id < ( LENGTH( tdav.attr_value ) - LENGTH( REPLACE ( tdav.attr_value,
|
|
|
|
';', '' ) ) + 1 )
|
2022-05-25 11:13:25 +08:00
|
|
|
WHERE
|
|
|
|
1 = 1
|
|
|
|
AND tdav.attr_type = '应用领域'
|
|
|
|
AND tdav.del_flag = 0
|
|
|
|
AND SUBSTRING_INDEX( SUBSTRING_INDEX( tdav.attr_value, ';', b.help_topic_id + 1 ), ';',- 1 ) != ''
|
|
|
|
GROUP BY
|
|
|
|
type
|
|
|
|
</select>
|
2022-06-25 08:58:04 +08:00
|
|
|
<select id="applicationAreaCapabilitySet" parameterType="java.util.Map" resultType="java.util.Map">
|
2022-06-25 09:24:30 +08:00
|
|
|
SELECT
|
2022-06-27 15:44:18 +08:00
|
|
|
SUBSTRING_INDEX( SUBSTRING_INDEX( tdav.attr_value, ';', b.help_topic_id + 1 ), ';',- 1 ) AS type ,
|
|
|
|
COUNT( tdav.data_resource_id ) AS total
|
2022-06-25 09:24:30 +08:00
|
|
|
FROM
|
2022-06-27 15:44:18 +08:00
|
|
|
tb_data_attr tdav
|
|
|
|
JOIN mysql.help_topic b ON b.help_topic_id < ( LENGTH( tdav.attr_value ) - LENGTH( REPLACE ( tdav.attr_value,
|
|
|
|
';', '' ) ) + 1 )
|
2022-06-25 09:24:30 +08:00
|
|
|
WHERE
|
2022-06-27 15:44:18 +08:00
|
|
|
1 = 1
|
|
|
|
AND tdav.attr_type = '应用领域'
|
|
|
|
AND tdav.del_flag = 0
|
|
|
|
AND SUBSTRING_INDEX( SUBSTRING_INDEX( tdav.attr_value, ';', b.help_topic_id + 1 ), ';',- 1 ) != ''
|
2022-06-25 09:24:30 +08:00
|
|
|
GROUP BY
|
2022-06-27 15:44:18 +08:00
|
|
|
type
|
2022-06-25 09:24:30 +08:00
|
|
|
</select>
|
|
|
|
<select id="applicationAreaCapabilityList" parameterType="java.util.Map" resultType="java.util.Map">
|
2022-06-25 08:58:04 +08:00
|
|
|
SELECT
|
2022-06-27 15:44:18 +08:00
|
|
|
SUBSTRING_INDEX( SUBSTRING_INDEX( tdav.attr_value, ';', b.help_topic_id + 1 ), ';',- 1 ) AS type ,
|
|
|
|
COUNT( tdav.data_resource_id ) AS total
|
2022-06-25 08:58:04 +08:00
|
|
|
FROM
|
2022-06-27 15:44:18 +08:00
|
|
|
(select a.* from tb_data_attr a inner join tb_data_resource c on a.data_resource_id = c.id where c.type =
|
|
|
|
#{resourceType} AND c.dept_id = #{id} ) tdav
|
|
|
|
JOIN mysql.help_topic b ON b.help_topic_id < ( LENGTH( tdav.attr_value ) - LENGTH( REPLACE ( tdav.attr_value,
|
|
|
|
';', '' ) ) + 1 )
|
2022-06-25 08:58:04 +08:00
|
|
|
WHERE
|
2022-06-27 15:44:18 +08:00
|
|
|
1 = 1
|
|
|
|
AND tdav.attr_type = '应用领域'
|
|
|
|
AND tdav.del_flag = 0
|
|
|
|
AND SUBSTRING_INDEX( SUBSTRING_INDEX( tdav.attr_value, ';', b.help_topic_id + 1 ), ';',- 1 ) != ''
|
2022-06-25 08:58:04 +08:00
|
|
|
GROUP BY
|
2022-06-27 15:44:18 +08:00
|
|
|
type
|
2022-06-25 08:58:04 +08:00
|
|
|
</select>
|
2022-06-27 17:30:14 +08:00
|
|
|
<select id="applicationAreaCapabilityUseList" parameterType="java.util.Map" resultType="java.util.Map">
|
|
|
|
SELECT
|
2022-06-28 17:48:29 +08:00
|
|
|
SUBSTRING_INDEX( SUBSTRING_INDEX( tdav.attr_value, ';', b.help_topic_id + 1 ), ';',- 1 ) AS type ,
|
|
|
|
COUNT( tdav.data_resource_id ) AS total
|
2022-06-27 17:30:14 +08:00
|
|
|
FROM
|
2022-06-28 17:48:29 +08:00
|
|
|
( select a.* from tb_data_attr a inner join tb_data_resource d on a.data_resource_id = d.id
|
|
|
|
inner join tb_data_resource_rel e on e.reference_id = d.id inner join sys_user f on e.creator = f.id where
|
|
|
|
d.type=#{resourceType}
|
|
|
|
and f.dept_id = #{id}
|
|
|
|
) tdav
|
2022-06-27 17:30:14 +08:00
|
|
|
JOIN mysql.help_topic b ON b.help_topic_id < ( LENGTH( tdav.attr_value ) - LENGTH( REPLACE ( tdav.attr_value,
|
2022-06-28 17:48:29 +08:00
|
|
|
';', '' ) ) + 1 )
|
2022-06-27 17:30:14 +08:00
|
|
|
WHERE
|
2022-06-28 17:48:29 +08:00
|
|
|
1 = 1
|
|
|
|
AND tdav.attr_type = '应用领域'
|
|
|
|
AND tdav.del_flag = 0
|
|
|
|
AND SUBSTRING_INDEX( SUBSTRING_INDEX( tdav.attr_value, ';', b.help_topic_id + 1 ), ';',- 1 ) != ''
|
2022-06-27 17:30:14 +08:00
|
|
|
GROUP BY
|
2022-06-28 17:48:29 +08:00
|
|
|
type
|
2022-06-27 17:30:14 +08:00
|
|
|
</select>
|
2022-05-25 11:13:25 +08:00
|
|
|
|
2022-06-19 17:14:53 +08:00
|
|
|
<select id="selectTopFiveComponentServiceApplications" resultType="java.util.Map">
|
|
|
|
SELECT
|
2022-06-20 10:23:37 +08:00
|
|
|
tdr.id AS "resourceId",
|
|
|
|
tdr.NAME AS "name",
|
|
|
|
IFNULL(COUNT( taa.id ), 0) AS "count"
|
2022-06-19 17:14:53 +08:00
|
|
|
FROM
|
2022-06-20 10:23:37 +08:00
|
|
|
tb_data_resource tdr
|
|
|
|
LEFT JOIN t_ability_application taa ON tdr.id = taa.resource_id AND taa.del_flag = 0
|
2022-06-19 17:14:53 +08:00
|
|
|
WHERE
|
2022-06-20 10:23:37 +08:00
|
|
|
1 = 1
|
|
|
|
AND tdr.del_flag = 0
|
|
|
|
AND tdr.type = '组件服务'
|
2022-06-19 17:14:53 +08:00
|
|
|
GROUP BY
|
2022-06-20 10:23:37 +08:00
|
|
|
tdr.id
|
2022-06-19 17:14:53 +08:00
|
|
|
ORDER BY
|
2022-06-20 10:23:37 +08:00
|
|
|
count DESC
|
2022-06-19 17:14:53 +08:00
|
|
|
LIMIT 5
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<select id="selectTopFiveComponentServiceScore" resultType="java.util.Map">
|
|
|
|
SELECT
|
2022-06-20 10:23:37 +08:00
|
|
|
tdr.id AS "resourceId",
|
|
|
|
tdr.NAME AS "name",
|
|
|
|
IFNULL( SUM( trs.score ), 0 ) AS "score"
|
2022-06-19 17:14:53 +08:00
|
|
|
FROM
|
2022-06-20 10:23:37 +08:00
|
|
|
tb_data_resource tdr
|
|
|
|
LEFT JOIN tb_resource_score trs ON tdr.id = trs.resource_id
|
|
|
|
AND trs.del_flag = 0
|
2022-06-19 17:14:53 +08:00
|
|
|
WHERE
|
2022-06-20 10:23:37 +08:00
|
|
|
1 = 1
|
|
|
|
AND tdr.del_flag = 0
|
|
|
|
AND tdr.type = '组件服务'
|
2022-06-19 17:14:53 +08:00
|
|
|
GROUP BY
|
2022-06-20 10:23:37 +08:00
|
|
|
tdr.id
|
2022-06-19 17:14:53 +08:00
|
|
|
ORDER BY
|
2022-06-20 10:23:37 +08:00
|
|
|
score DESC
|
2022-06-19 17:14:53 +08:00
|
|
|
LIMIT 5
|
|
|
|
</select>
|
|
|
|
|
2022-06-24 16:37:14 +08:00
|
|
|
<select id="selectResourceNumAsType" parameterType="java.util.Map" resultType="java.util.Map">
|
|
|
|
SELECT COUNT(b.id) AS resourceNum,
|
2022-06-27 15:44:18 +08:00
|
|
|
a.id AS deptId,
|
|
|
|
a.name AS deptName,
|
|
|
|
SUM(b.visits) AS visits
|
2022-06-24 16:37:14 +08:00
|
|
|
FROM
|
|
|
|
sys_dept a
|
|
|
|
INNER JOIN
|
|
|
|
tb_data_resource b
|
|
|
|
ON
|
|
|
|
a.id = b.dept_id
|
|
|
|
WHERE
|
|
|
|
b.del_flag = 0
|
|
|
|
AND
|
|
|
|
b.type = '组件服务'
|
|
|
|
<if test="id != null and id != ''">
|
|
|
|
AND (a.pids LIKE concat(concat('%',#{id}),'%') OR a.id = #{id})
|
|
|
|
</if>
|
|
|
|
GROUP BY
|
|
|
|
a.name,a.id
|
|
|
|
ORDER BY
|
|
|
|
a.name,a.id
|
|
|
|
LIMIT ${pageNum}, ${pageSize}
|
|
|
|
</select>
|
|
|
|
<select id="selectResourceCarNum" parameterType="java.util.Map" resultType="integer">
|
|
|
|
SELECT COUNT(a.id) as resourceCarNum
|
|
|
|
FROM
|
|
|
|
tb_resource_car a
|
|
|
|
INNER JOIN
|
|
|
|
tb_data_resource b
|
|
|
|
ON
|
|
|
|
a.resource_id = b.id
|
|
|
|
WHERE
|
|
|
|
a.del_flag = 0
|
|
|
|
<if test="id != null and id != ''">
|
|
|
|
and b.dept_id = #{id}
|
|
|
|
</if>
|
|
|
|
<if test="resourceType != null and resourceType != ''">
|
|
|
|
AND b.type = #{resourceType}
|
|
|
|
</if>
|
|
|
|
|
|
|
|
</select>
|
|
|
|
<select id="selectResourceCollectionNum" parameterType="java.util.Map" resultType="integer">
|
|
|
|
SELECT COUNT(a.id) as resourceCollectionNum
|
|
|
|
FROM
|
|
|
|
tb_resource_collection a
|
|
|
|
INNER JOIN
|
|
|
|
tb_data_resource b
|
|
|
|
ON
|
|
|
|
a.resource_id = b.id
|
|
|
|
WHERE
|
|
|
|
a.del_flag = 0
|
|
|
|
<if test="id != null and id != ''">
|
|
|
|
and b.dept_id = #{id}
|
|
|
|
</if>
|
|
|
|
<if test="resourceType != null and resourceType != ''">
|
|
|
|
AND b.type = #{resourceType}
|
|
|
|
</if>
|
|
|
|
</select>
|
|
|
|
<select id="selectResourceBrowseNum" parameterType="java.util.Map" resultType="integer">
|
|
|
|
SELECT COUNT(a.id) as resourceBrowseNum
|
|
|
|
FROM
|
|
|
|
tb_resource_browse a
|
|
|
|
INNER JOIN
|
|
|
|
tb_data_resource b
|
|
|
|
ON
|
|
|
|
a.resource_id = b.id
|
|
|
|
WHERE
|
|
|
|
a.state = 0
|
|
|
|
<if test="id != null and id != ''">
|
|
|
|
and b.dept_id = #{id}
|
|
|
|
</if>
|
|
|
|
<if test="resourceType != null and resourceType != ''">
|
|
|
|
AND b.type = #{resourceType}
|
|
|
|
</if>
|
|
|
|
</select>
|
|
|
|
<select id="selectResourceRelNum" parameterType="java.util.Map" resultType="integer">
|
|
|
|
SELECT COUNT(a.key_id) as resourceBrowseNum
|
|
|
|
FROM
|
|
|
|
tb_data_resource_rel a
|
|
|
|
INNER JOIN
|
|
|
|
tb_data_resource b
|
|
|
|
ON
|
|
|
|
a.reference_id = b.id
|
|
|
|
WHERE
|
|
|
|
a.del_flag = 0
|
|
|
|
<if test="id != null and id != ''">
|
2022-06-27 15:44:18 +08:00
|
|
|
and b.dept_id = #{id}
|
2022-06-24 16:37:14 +08:00
|
|
|
</if>
|
|
|
|
<if test="resourceType != null and resourceType != ''">
|
|
|
|
AND b.type = #{resourceType}
|
|
|
|
</if>
|
|
|
|
</select>
|
|
|
|
<select id="selectResourceShare" parameterType="java.util.Map" resultType="integer">
|
|
|
|
SELECT COUNT(id) AS nums
|
|
|
|
FROM
|
2022-06-27 15:44:18 +08:00
|
|
|
tb_data_resource
|
2022-06-24 16:37:14 +08:00
|
|
|
WHERE
|
|
|
|
del_flag = 0
|
|
|
|
<if test="id != null and id != ''">
|
|
|
|
and
|
|
|
|
dept_id = #{id}
|
|
|
|
</if>
|
|
|
|
<if test="resourceType != null and resourceType != ''">
|
|
|
|
AND
|
|
|
|
type = #{resourceType}
|
|
|
|
</if>
|
|
|
|
<if test="shareCondition != null and shareCondition != ''">
|
|
|
|
AND
|
|
|
|
share_condition = #{shareCondition}
|
|
|
|
</if>
|
|
|
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<select id="selectResurceCarDetails" parameterType="java.util.Map" resultType="java.util.Map">
|
|
|
|
SELECT COUNT(a.id) AS resourceCarNum,
|
2022-06-28 17:48:29 +08:00
|
|
|
c.name as deptName,c.id,COUNT(e.id) as useNum
|
2022-06-24 16:37:14 +08:00
|
|
|
FROM
|
2022-06-28 17:48:29 +08:00
|
|
|
tb_resource_car a
|
2022-06-24 16:37:14 +08:00
|
|
|
INNER JOIN
|
2022-06-28 17:48:29 +08:00
|
|
|
sys_user b
|
2022-06-24 16:37:14 +08:00
|
|
|
ON
|
2022-06-28 17:48:29 +08:00
|
|
|
a.user_id = b.id
|
2022-06-24 16:37:14 +08:00
|
|
|
INNER JOIN
|
2022-06-28 17:48:29 +08:00
|
|
|
sys_dept c
|
2022-06-24 16:37:14 +08:00
|
|
|
ON
|
2022-06-28 17:48:29 +08:00
|
|
|
b.dept_id = c.id
|
2022-06-24 16:37:14 +08:00
|
|
|
INNER JOIN
|
2022-06-28 17:48:29 +08:00
|
|
|
tb_data_resource d
|
2022-06-24 16:37:14 +08:00
|
|
|
ON
|
2022-06-28 17:48:29 +08:00
|
|
|
a.resource_id = d.id
|
2022-06-27 17:30:14 +08:00
|
|
|
INNER JOIN tb_data_resource_rel e
|
|
|
|
ON
|
2022-06-28 17:48:29 +08:00
|
|
|
b.id = e.creator
|
2022-06-24 16:37:14 +08:00
|
|
|
where
|
2022-06-28 17:48:29 +08:00
|
|
|
(c.id = #{id} or c.pids LIKE CONCAT('%',CONCAT(#{id},'%')))
|
|
|
|
AND
|
|
|
|
d.type = #{resourceType}
|
|
|
|
AND
|
|
|
|
a.del_flag = 0
|
|
|
|
AND
|
|
|
|
d.del_flag = 0
|
2022-06-24 16:37:14 +08:00
|
|
|
group by
|
2022-06-28 17:48:29 +08:00
|
|
|
c.name,c.id
|
2022-06-24 16:37:14 +08:00
|
|
|
order by
|
2022-06-28 17:48:29 +08:00
|
|
|
c.name,c.id
|
2022-06-24 16:37:14 +08:00
|
|
|
LIMIT ${pageNum}, ${pageSize}
|
|
|
|
</select>
|
2022-06-25 14:50:43 +08:00
|
|
|
|
2022-06-28 15:50:46 +08:00
|
|
|
<!-- 根据组件类型查询部门申请组件的数量-->
|
2022-06-28 17:48:29 +08:00
|
|
|
<select id="assemblyCarByDept" parameterType="java.util.Map" resultType="java.util.Map">
|
|
|
|
SELECT COUNT(distinct(a.resource_id)) as carNum,c.id FROM tb_resource_car a INNER JOIN sys_user b ON a.creator =
|
|
|
|
b.id INNER JOIN sys_dept c ON b.dept_id = c.id INNER JOIN tb_data_resource d on a.resource_id = d.id
|
|
|
|
WHERE a.del_flag = 0 AND d.type = #{resourceType} AND (c.id =#{id} or INSTR(c.pids,#{id})) group by c.id
|
2022-06-28 10:33:09 +08:00
|
|
|
</select>
|
|
|
|
|
2022-06-28 15:50:46 +08:00
|
|
|
<!--根据组件类型查询部门使用组件的数量-->
|
2022-06-28 17:48:29 +08:00
|
|
|
<select id="assemblyUseByDept" parameterType="java.util.Map" resultType="java.util.Map">
|
|
|
|
SELECT COUNT(distinct(a.key_id)) as useNum,c.id FROM tb_data_resource_rel a INNER JOIN sys_user b ON a.creator =
|
|
|
|
b.id INNER JOIN sys_dept c ON b.dept_id = c.id INNER JOIN tb_data_resource d on a.key_id = d.id
|
|
|
|
WHERE a.del_flag = 0 AND d.type = #{resourceType} AND (c.id = #{id} or INSTR(c.pids,#{id} )) group by c.id
|
2022-06-28 10:33:09 +08:00
|
|
|
</select>
|
2022-06-25 14:50:43 +08:00
|
|
|
|
2022-06-29 16:10:35 +08:00
|
|
|
<select id="selectCountByDepts" resultType="java.util.Map">
|
2022-06-29 10:11:03 +08:00
|
|
|
SELECT
|
|
|
|
type,
|
|
|
|
count(id) AS "count"
|
|
|
|
FROM tb_data_resource
|
|
|
|
WHERE 1=1
|
|
|
|
AND del_flag = 0
|
|
|
|
AND dept_id in
|
|
|
|
<foreach item="deptId" collection="list" open="(" separator="," close=")">
|
|
|
|
#{deptId}
|
|
|
|
</foreach>
|
|
|
|
GROUP BY type
|
|
|
|
ORDER BY type
|
|
|
|
</select>
|
|
|
|
|
2022-06-29 16:10:35 +08:00
|
|
|
<select id="selectCountByIds" resultType="java.util.Map">
|
|
|
|
SELECT
|
|
|
|
type,
|
|
|
|
count(id) AS "count"
|
|
|
|
FROM tb_data_resource
|
|
|
|
WHERE 1=1
|
|
|
|
AND del_flag = 0
|
|
|
|
AND id in
|
|
|
|
<foreach item="resourceId" collection="list" open="(" separator="," close=")">
|
|
|
|
#{resourceId}
|
|
|
|
</foreach>
|
|
|
|
GROUP BY type
|
|
|
|
ORDER BY type
|
|
|
|
</select>
|
|
|
|
|
2022-06-29 20:50:41 +08:00
|
|
|
<select id="selectDeptResourceByApplyNum" resultType="java.util.Map">
|
|
|
|
SELECT count(trma.id) as count, tdr.name
|
|
|
|
FROM tb_data_resource tdr left join t_resource_mount_apply trma on tdr.id=trma.resource_id
|
|
|
|
where tdr.dept_id in
|
|
|
|
<foreach item="deptId" collection="list" open="(" separator="," close=")">
|
|
|
|
#{deptId}
|
|
|
|
</foreach>
|
|
|
|
group by tdr.id order by count desc
|
|
|
|
</select>
|
|
|
|
|
2022-06-29 19:25:11 +08:00
|
|
|
<select id="selectCameraDTOById" resultMap="resourceDTO">
|
|
|
|
</select>
|
|
|
|
|
2022-04-14 13:58:19 +08:00
|
|
|
</mapper>
|