You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
753 lines
31 KiB
753 lines
31 KiB
<?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="com.epmet.dao.ProjectDao">
|
|
|
|
<resultMap type="com.epmet.entity.ProjectEntity" id="projectMap">
|
|
<result property="id" column="ID"/>
|
|
<result property="agencyId" column="AGENCY_ID"/>
|
|
<result property="origin" column="ORIGIN"/>
|
|
<result property="originId" column="ORIGIN_ID"/>
|
|
<result property="title" column="TITLE"/>
|
|
<result property="status" column="STATUS"/>
|
|
<result property="closedStatus" column="CLOSED_STATUS"/>
|
|
<result property="orgIdPath" column="ORG_ID_PATH"/>
|
|
<result property="delFlag" column="DEL_FLAG"/>
|
|
<result property="revision" column="REVISION"/>
|
|
<result property="createdBy" column="CREATED_BY"/>
|
|
<result property="createdTime" column="CREATED_TIME"/>
|
|
<result property="updatedBy" column="UPDATED_BY"/>
|
|
<result property="updatedTime" column="UPDATED_TIME"/>
|
|
</resultMap>
|
|
<select id="selectPendList" resultType="com.epmet.dto.ProjectDTO" parameterType="com.epmet.dto.form.ProjectListFromDTO">
|
|
SELECT distinct
|
|
p.ID,
|
|
p.TITLE,
|
|
p.CREATED_TIME,
|
|
psp.CREATED_TIME AS UPDATED_TIME
|
|
FROM project p
|
|
INNER JOIN (SELECT
|
|
ps.PROJECT_ID,
|
|
MAX(ps.CREATED_TIME) AS CREATED_TIME
|
|
FROM
|
|
project_staff ps
|
|
WHERE
|
|
ps.DEL_FLAG = '0'
|
|
AND ps.IS_HANDLE = 'unhandled'
|
|
AND ps.STAFF_ID = #{userId}
|
|
GROUP BY ps.PROJECT_ID) psp ON p.ID = psp.PROJECT_ID
|
|
WHERE p.DEL_FLAG = '0'
|
|
AND p.status = 'pending'
|
|
ORDER BY psp.created_time, p.created_time ASC<!-- 先按滞留时间降序再按创建时间升序(带奇峰修改) -->
|
|
LIMIT #{pageNo}, #{pageSize}
|
|
</select>
|
|
|
|
|
|
<select id="selectCreatedList" resultType="com.epmet.dto.ProjectDTO" parameterType="com.epmet.dto.form.ProjectListFromDTO">
|
|
SELECT distinct
|
|
p.ID,
|
|
p.TITLE,
|
|
p.STATUS,
|
|
IFNULL(pp.PUBLIC_REPLY, "") AS PUBLIC_REPLY,
|
|
p.CREATED_TIME,
|
|
ps.CREATED_TIME AS UPDATED_TIME
|
|
FROM project p
|
|
INNER JOIN (SELECT
|
|
PROJECT_ID
|
|
FROM
|
|
project_process
|
|
WHERE
|
|
DEL_FLAG = '0'
|
|
AND OPERATION = 'created'
|
|
AND STAFF_ID = #{userId}
|
|
) psp ON p.ID = psp.PROJECT_ID
|
|
LEFT JOIN (
|
|
SELECT DISTINCT
|
|
PROJECT_ID,
|
|
MIN(CREATED_TIME) AS CREATED_TIME
|
|
FROM
|
|
project_staff
|
|
WHERE DEL_FLAG = '0'
|
|
AND IS_HANDLE = 'unhandled'
|
|
GROUP BY PROJECT_ID) ps ON p.ID = ps.PROJECT_ID
|
|
LEFT JOIN project_process pp ON p.ID = pp.PROJECT_ID AND pp.OPERATION = 'close'
|
|
WHERE
|
|
p.DEL_FLAG = '0'
|
|
ORDER BY p.CREATED_TIME ASC
|
|
LIMIT #{pageNo}, #{pageSize}
|
|
</select>
|
|
<select id="selectInvolvedList" resultType="com.epmet.dto.ProjectDTO" parameterType="com.epmet.dto.form.ProjectListFromDTO">
|
|
SELECT distinct
|
|
p.ID,
|
|
p.TITLE,
|
|
p.STATUS,
|
|
IFNULL(pp.PUBLIC_REPLY, "") AS PUBLIC_REPLY,
|
|
p.CREATED_TIME,
|
|
ps.CREATED_TIME AS UPDATED_TIME
|
|
FROM project p
|
|
INNER JOIN (SELECT
|
|
ps.PROJECT_ID
|
|
FROM
|
|
project_staff ps
|
|
INNER JOIN project_process pp ON ps.PROCESS_ID = pp.ID AND pp.DEL_FLAG = '0'
|
|
AND (pp.OPERATION != 'created'
|
|
OR (pp.OPERATION = 'created' AND pp.STAFF_ID != #{userId}))
|
|
WHERE
|
|
ps.DEL_FLAG = '0'
|
|
AND ps.STAFF_ID = #{userId}
|
|
GROUP BY ps.PROJECT_ID) psp ON p.ID = psp.PROJECT_ID
|
|
LEFT JOIN (
|
|
SELECT DISTINCT
|
|
PROJECT_ID,
|
|
MIN(CREATED_TIME) AS CREATED_TIME
|
|
FROM
|
|
project_staff
|
|
WHERE DEL_FLAG = '0'
|
|
AND IS_HANDLE = 'unhandled'
|
|
GROUP BY PROJECT_ID) ps ON p.ID = ps.PROJECT_ID
|
|
LEFT JOIN project_process pp ON p.ID = pp.PROJECT_ID AND pp.OPERATION = 'close'
|
|
WHERE
|
|
p.DEL_FLAG = '0'
|
|
ORDER BY p.CREATED_TIME ASC
|
|
LIMIT #{pageNo}, #{pageSize}
|
|
</select>
|
|
<select id="selectDepartmentNameList" resultType="java.lang.String" parameterType="com.epmet.dto.ProjectDTO">
|
|
SELECT DISTINCT
|
|
DEPARTMENT_NAME
|
|
FROM
|
|
project p
|
|
INNER JOIN project_staff ps ON p.ID = ps.PROJECT_ID
|
|
WHERE p.DEL_FLAG = '0'
|
|
AND ps.DEL_FLAG = '0'
|
|
AND p.ID = #{id}
|
|
AND ps.IS_HANDLE = 'unhandled'
|
|
</select>
|
|
<select id="selectProjectDetail" resultType="com.epmet.dto.result.ProjectDetailResultDTO">
|
|
SELECT
|
|
p.ID AS "projectId",
|
|
p.TITLE AS "projectTitle",
|
|
p.BACK_GROUND AS "backGround",
|
|
p.ORIGIN AS "origin",
|
|
p.ORIGIN_ID AS "originId",
|
|
p.STATUS AS "projectStatus",
|
|
p.locate_address AS "locateAddress",
|
|
p.locate_longitude AS "locateLongitude",
|
|
p.locate_dimension AS "locateDimension",
|
|
IFNULL(pp.PUBLIC_REPLY, '无') AS "publicReply",
|
|
IFNULL(pp.INTERNAL_REMARK, '无') AS "internalRemark"
|
|
FROM project p
|
|
INNER JOIN project_process pp ON p.ID = pp.PROJECT_ID AND pp.DEL_FLAG = '0' AND pp.OPERATION = 'created'
|
|
WHERE p.DEL_FLAG = '0'
|
|
AND p.ID = #{id}
|
|
</select>
|
|
<select id="selectShiftProjectList" resultType="com.epmet.dto.ProjectDTO" parameterType="com.epmet.dto.form.ShiftProjectsFromDTO">
|
|
SELECT p.*, IFNULL(pp.PUBLIC_REPLY, "") AS PUBLIC_REPLY FROM project p
|
|
LEFT JOIN (SELECT PROJECT_ID,
|
|
PUBLIC_REPLY
|
|
FROM
|
|
project_process
|
|
WHERE DEL_FLAG = '0'
|
|
AND OPERATION = 'close') pp ON p.ID = pp.PROJECT_ID
|
|
WHERE p.DEL_FLAG = '0'
|
|
AND p.ORIGIN = 'issue'
|
|
<foreach item="issueId" collection="issueIds" separator="OR" open="AND (" close=")" index="">
|
|
p.ORIGIN_ID = #{issueId}
|
|
</foreach>
|
|
ORDER BY CREATED_TIME ASC
|
|
</select>
|
|
|
|
<select id="selectClosedProjectList" resultType="com.epmet.dto.result.LatestListResultDTO">
|
|
SELECT DISTINCT
|
|
p.id AS "projectId",
|
|
pro.public_reply AS "publicReply",
|
|
pro.department_name AS "departmentName",
|
|
UNIX_TIMESTAMP(pro.created_time) AS "closeProjectTime"
|
|
FROM project p
|
|
INNER JOIN project_process pro ON p.id = pro.project_id
|
|
INNER JOIN project_related_personnel prp ON p.id = prp.project_id
|
|
WHERE p.del_flag = '0'
|
|
AND pro.del_flag = '0'
|
|
AND p.customer_id = #{customerId}
|
|
AND p.`status` = 'closed'
|
|
AND pro.operation = 'close'
|
|
AND p.origin = 'issue'
|
|
AND prp.source_type = 'issue'
|
|
AND prp.grid_id = #{gridId}
|
|
ORDER BY pro.created_time DESC
|
|
LIMIT #{num}, #{pageSize}
|
|
</select>
|
|
|
|
<select id="selectProjectList" resultType="com.epmet.dto.ProjectDTO">
|
|
SELECT
|
|
id,
|
|
customer_id,
|
|
agency_id,
|
|
origin,
|
|
origin_id,
|
|
title
|
|
FROM
|
|
project
|
|
WHERE
|
|
del_flag = '0'
|
|
AND customer_id = #{customerId}
|
|
AND agency_id = #{agencyId}
|
|
AND origin = #{origin}
|
|
AND origin_id = #{originId}
|
|
</select>
|
|
<select id="selectCurrentDepartmentList" resultType="com.epmet.dto.ProjectStaffDTO">
|
|
SELECT DISTINCT
|
|
DEPARTMENT_NAME,
|
|
STAFF_ID
|
|
FROM
|
|
project p
|
|
INNER JOIN project_staff ps ON p.ID = ps.PROJECT_ID
|
|
WHERE p.DEL_FLAG = '0'
|
|
AND ps.DEL_FLAG = '0'
|
|
AND p.ID = #{id}
|
|
AND ps.IS_HANDLE = 'unhandled'
|
|
</select>
|
|
|
|
<select id="selectAllCustomerIds" resultType="string">
|
|
SELECT
|
|
distinct
|
|
CUSTOMER_ID
|
|
FROM
|
|
PROJECT
|
|
WHERE
|
|
DEL_FLAG = '0'
|
|
</select>
|
|
|
|
<select id="selectIssueProjectList" resultType="com.epmet.dto.result.MyPartProjectsResultDTO">
|
|
SELECT
|
|
id AS "projectId",
|
|
title AS "projectTitle",
|
|
UNIX_TIMESTAMP(created_time) AS "shiftProjectTime",
|
|
origin_id AS "issueId",
|
|
status AS "status"
|
|
FROM
|
|
project
|
|
WHERE
|
|
del_flag = '0'
|
|
AND origin = 'issue'
|
|
AND customer_id = #{customerId}
|
|
<foreach collection="issueList" item="issueId" open="AND( " separator=" OR " index="index" close=")">
|
|
origin_id = #{issueId}
|
|
</foreach>
|
|
ORDER BY CREATED_TIME DESC
|
|
LIMIT #{pageIndex}, #{pageSize}
|
|
</select>
|
|
|
|
<select id="listProjectsByCreateTopicUserId"
|
|
resultType="com.epmet.dto.result.ProjectOfCreateTopicUserResultDTO">
|
|
select
|
|
rp.SOURCE_ID as topicId,
|
|
unix_timestamp(p.CREATED_TIME) as shiftProjectTime,
|
|
p.id as projectId,
|
|
rp.GRID_ID gridId,
|
|
p.TITLE as projectTitle,
|
|
rp.GRID_ID releaseGridId,
|
|
rp2.SOURCE_ID as issueId
|
|
from project_related_personnel rp
|
|
inner join project p on (rp.PROJECT_ID = p.ID and p.DEL_FLAG = 0)
|
|
left join project_related_personnel rp2 on (rp.PROJECT_ID = rp2.PROJECT_ID and rp2.SOURCE_TYPE = 'issue')
|
|
where rp.USER_ID = #{userId}
|
|
and p.CUSTOMER_ID=#{customerId}
|
|
and p.DEL_FLAG=0
|
|
and rp.SOURCE_TYPE = 'topic'
|
|
order by p.CREATED_TIME desc
|
|
</select>
|
|
|
|
<resultMap type="com.epmet.dto.result.ProjectInfoDTO" id="ProjectInfoDTOMap">
|
|
<result property="projectId" column="ID"/>
|
|
<result property="issueId" column="ORIGIN_ID"/>
|
|
<result property="eventTitle" column="TITLE"/>
|
|
<result property="eventContent" column="TITLE1"/>
|
|
<collection property="imgUrlList" ofType="java.lang.String">
|
|
<constructor>
|
|
<arg column="imgUrl"/>
|
|
</constructor>
|
|
</collection>
|
|
</resultMap>
|
|
|
|
<select id="queryProjectInfoByProjectId" resultMap="ProjectInfoDTOMap" parameterType="java.lang.String">
|
|
select p.id,p.TITLE,p.TITLE as TITLE1,P.ORIGIN_ID,
|
|
M.ATTACHMENT_URL AS imgUrl
|
|
from project p
|
|
LEFT JOIN project_process_attachment M
|
|
ON(P.ID=M.PROJECT_ID AND M.DEL_FLAG='0'
|
|
AND M.ATTACHMENT_TYPE='image')
|
|
where P.DEL_FLAG='0'
|
|
AND p.id=#{projectId}
|
|
</select>
|
|
|
|
<!-- 查询所以已关闭的项目【项目来源为 'issue'】 -->
|
|
<select id="selectAllClosedProject" resultType="com.epmet.dto.result.ComplementedProjectEvaluateResultDTO">
|
|
SELECT
|
|
ID AS projectId,
|
|
ORIGIN_ID AS issueId,
|
|
CUSTOMER_ID
|
|
FROM project
|
|
WHERE DEL_FLAG = '0'
|
|
AND ORIGIN = 'issue'
|
|
AND `STATUS` = 'closed'
|
|
</select>
|
|
|
|
<!-- 查询时间段内的项目ID -->
|
|
<select id="selectProjectIdByTime" resultType="com.epmet.dto.result.MassesDiscontentResultDTO">
|
|
SELECT
|
|
ID AS projectId,
|
|
ORIGIN_ID AS issueId
|
|
FROM project
|
|
WHERE
|
|
DEL_FLAG = '0'
|
|
AND DATE_FORMAT(CREATED_TIME,'%Y%m%d') >= #{startDate}
|
|
AND DATE_FORMAT(CREATED_TIME,'%Y%m%d') <![CDATA[ <= ]]> #{endDate}
|
|
AND ORG_ID_PATH LIKE CONCAT('%',#{agencyId},'%')
|
|
AND ORIGIN = 'issue'
|
|
AND `STATUS` = 'closed'
|
|
</select>
|
|
|
|
<!-- 查询巡查期间的立项数 -->
|
|
<select id="selectPatrolProject" resultType="java.lang.Integer">
|
|
SELECT
|
|
COUNT(1)
|
|
FROM
|
|
project
|
|
WHERE DEL_FLAG = '0'
|
|
AND CREATED_TIME BETWEEN #{patrolStartTime} AND #{patrolEndTime}
|
|
AND ORIGIN = 'work_event'
|
|
AND CREATED_BY = #{userId}
|
|
</select>
|
|
<select id="selectPendingListByGrid" resultType="com.epmet.dto.result.PendingResultDTO">
|
|
SELECT
|
|
a.ID AS projectId,
|
|
a.ORIGIN_ID AS issueId,
|
|
a.TITLE AS issueTitle,
|
|
UNIX_TIMESTAMP(a.CREATED_TIME) AS issueShiftedTime,
|
|
b.SOURCE_ID AS sourceId
|
|
FROM
|
|
project a
|
|
INNER JOIN project_related_personnel b ON a.ID = b.PROJECT_ID
|
|
AND b.SOURCE_TYPE = 'topic'
|
|
AND b.GRID_ID = #{gridId}
|
|
WHERE
|
|
a.DEL_FLAG = '0'
|
|
AND a.`STATUS` = 'pending'
|
|
AND a.ORIGIN = 'issue'
|
|
ORDER BY a.CREATED_TIME DESC
|
|
</select>
|
|
<select id="selectResolvedListByGrid" resultType="com.epmet.dto.result.ResolvedResultDTO">
|
|
SELECT
|
|
a.ORIGIN_ID AS issueId,
|
|
a.TITLE AS issueTitle,
|
|
c.PUBLIC_REPLY AS publicReply,
|
|
UNIX_TIMESTAMP(a.UPDATED_TIME) AS closedTime,
|
|
b.SOURCE_ID AS sourceId
|
|
FROM
|
|
project a
|
|
INNER JOIN project_related_personnel b ON a.ID = b.PROJECT_ID
|
|
AND b.SOURCE_TYPE = 'topic'
|
|
AND b.GRID_ID = #{gridId}
|
|
LEFT JOIN project_process c ON a.ID = c.PROJECT_ID
|
|
AND c.OPERATION = 'close'
|
|
WHERE
|
|
a.DEL_FLAG = '0'
|
|
AND a.`STATUS` = 'closed'
|
|
AND a.ORIGIN = 'issue'
|
|
AND a.CLOSED_STATUS = 'resolved'
|
|
ORDER BY a.UPDATED_TIME DESC
|
|
</select>
|
|
<select id="selectUnResolvedListByGrid" resultType="com.epmet.dto.result.UnResolvedResultDTO">
|
|
SELECT
|
|
a.ORIGIN_ID AS issueId,
|
|
a.TITLE AS issueTitle,
|
|
c.PUBLIC_REPLY AS solution,
|
|
UNIX_TIMESTAMP(a.UPDATED_TIME) AS closedTime,
|
|
b.SOURCE_ID AS sourceId
|
|
FROM
|
|
project a
|
|
INNER JOIN project_related_personnel b ON a.ID = b.PROJECT_ID
|
|
AND b.SOURCE_TYPE = 'topic'
|
|
AND b.GRID_ID = #{gridId}
|
|
LEFT JOIN project_process c ON a.ID = c.PROJECT_ID
|
|
AND c.OPERATION = 'close'
|
|
WHERE
|
|
a.DEL_FLAG = '0'
|
|
AND a.`STATUS` = 'closed'
|
|
AND a.ORIGIN = 'issue'
|
|
AND a.CLOSED_STATUS = 'unresolved'
|
|
ORDER BY a.UPDATED_TIME DESC
|
|
</select>
|
|
|
|
<!-- 查询报事转项目详情 -->
|
|
<select id="selectEventProjectInfo" resultType="com.epmet.dto.EventProjectInfoDTO">
|
|
SELECT
|
|
p.ID AS projectId,
|
|
IFNULL(DATE_FORMAT(p.CREATED_TIME,'%Y-%m-%d %h:%i'),'') AS operationTime,
|
|
p.CREATED_BY AS userId,
|
|
IFNULL(pp.PUBLIC_REPLY,'') AS projectDeclare
|
|
FROM project p
|
|
LEFT JOIN project_process pp ON (pp.PROJECT_ID = p.ID AND pp.DEL_FLAG = '0' AND pp.OPERATION = 'created')
|
|
WHERE p.DEL_FLAG = '0'
|
|
AND p.ID = #{projectId}
|
|
</select>
|
|
|
|
<select id="selectByOriginId" resultType="com.epmet.entity.ProjectEntity">
|
|
select p.id from project p
|
|
where p.DEL_FLAG = '0'
|
|
AND p.ORIGIN_ID = #{originId}
|
|
</select>
|
|
|
|
<!-- 根据日期查询项目分类 -->
|
|
<select id="selectProjectCategoryByDate" resultType="com.epmet.dto.result.ProjectCategoryByDateDTO">
|
|
SELECT
|
|
DISTINCT p.ID AS projectId,
|
|
CONCAT(#{startDate},' ', DATE_FORMAT(p.CREATED_TIME,'%H:%i:%s')) AS createdTime,
|
|
LEFT(pc.CATEGORY_CODE,#{codeLength}) AS categoryCode
|
|
FROM project p
|
|
INNER JOIN project_category pc ON (pc.PROJECT_ID = p.ID AND pc.DEL_FLAG = 0)
|
|
WHERE p.DEL_FLAG = 0
|
|
AND p.ORG_ID_PATH LIKE CONCAT('%',#{orgId},'%')
|
|
AND DATE_FORMAT(p.CREATED_TIME,'%Y-%m-%d') >= #{startDate}
|
|
AND DATE_FORMAT(p.CREATED_TIME,'%Y-%m-%d') <![CDATA[ <= ]]> #{endDate}
|
|
ORDER BY projectId
|
|
</select>
|
|
|
|
<!-- 数据分析-个人档案-事件详情页面的研判分析项目列表 -->
|
|
<select id="selectCommonCategoryEventProject" parameterType="map" resultType="com.epmet.dto.result.ProjectInfoIcData">
|
|
select
|
|
distinct pc.PROJECT_ID as projectId,
|
|
p.TITLE as projectTitle,
|
|
p.ORIGIN_ID as resiEventId,
|
|
p.`STATUS` as projectStatus,
|
|
'' as issueId,
|
|
'' as topicId
|
|
from project_category pc
|
|
inner join project p
|
|
on(pc.PROJECT_ID=p.id)
|
|
inner join resi_event re
|
|
on(p.ORIGIN_ID=re.id)
|
|
where pc.DEL_FLAG='0'
|
|
and p.DEL_FLAG='0'
|
|
and re.DEL_FLAG='0'
|
|
and pc.CUSTOMER_ID=#{customerId}
|
|
and p.ORIGIN='resi_event'
|
|
and pc.PROJECT_ID !=#{excludeProjectId}
|
|
<foreach collection="epmetUserIds" item="epmetUserId" open="AND( " separator=" OR " index="index" close=")">
|
|
re.REPORT_USER_ID = #{epmetUserId}
|
|
</foreach>
|
|
and pc.CATEGORY_CODE like concat(#{categoryCode},'%')
|
|
order by p.CREATED_TIME desc
|
|
</select>
|
|
|
|
<!-- 数据分析-个人档案-话题详情页面的研判分析项目列表 -->
|
|
<select id="selectCommonCategoryIssueProject" parameterType="map" resultType="com.epmet.dto.result.ProjectInfoIcData">
|
|
SELECT
|
|
DISTINCT
|
|
pc.PROJECT_ID AS projectId,
|
|
p.TITLE AS projectTitle,
|
|
p.ORIGIN_ID AS issueId,
|
|
per.SOURCE_ID as topicId,
|
|
p.`STATUS` AS projectStatus,
|
|
'' as resiEventId
|
|
FROM
|
|
project_category pc
|
|
INNER JOIN project_related_personnel per ON ( pc.PROJECT_ID = per.PROJECT_ID )
|
|
INNER JOIN project p on(pc.project_id=p.id)
|
|
WHERE
|
|
pc.DEL_FLAG = '0'
|
|
AND per.DEL_FLAG = '0'
|
|
AND p.DEL_FLAG = '0'
|
|
AND pc.CUSTOMER_ID = #{customerId}
|
|
AND p.ORIGIN = 'issue'
|
|
and per.SOURCE_TYPE='topic'
|
|
AND pc.PROJECT_ID != #{excludeProjectId}
|
|
AND pc.CATEGORY_CODE LIKE concat( #{categoryCode}, '%' )
|
|
<foreach collection="epmetUserIds" item="epmetUserId" open="AND( " separator=" OR " index="index" close=")">
|
|
per.USER_ID = #{epmetUserId}
|
|
</foreach>
|
|
ORDER BY
|
|
p.CREATED_TIME DESC
|
|
</select>
|
|
|
|
<!-- 查询组织下的项目数 -->
|
|
<select id="selectProjectCountByOrg" resultType="com.epmet.dto.result.ProjectDistributionAnalysisRightDTO">
|
|
<foreach collection="orgIds" item="o" separator=" UNION ALL ">
|
|
SELECT
|
|
#{o.orgId} AS orgId,
|
|
COUNT(ID) AS count
|
|
FROM project
|
|
WHERE DEL_FLAG = '0'
|
|
AND ORG_ID_PATH LIKE CONCAT(#{o.pids},':',#{o.orgId},'%')
|
|
AND DATE_FORMAT(CREATED_TIME,'%Y-%m-%d') >= #{startDate}
|
|
AND DATE_FORMAT(CREATED_TIME,'%Y-%m-%d') <![CDATA[ <= ]]> #{endDate}
|
|
</foreach>
|
|
</select>
|
|
<select id="getGridMemberProjectList" resultType="com.epmet.dto.result.ApprovaledListResultDTO">
|
|
SELECT
|
|
ID AS "projectId",
|
|
TITLE,
|
|
LOCATE_ADDRESS,
|
|
DATE_FORMAT( CREATED_TIME, '%Y-%m-%d' ) AS "happenTime",
|
|
CREATED_BY AS "staffId",
|
|
DATE_FORMAT( CREATED_TIME, '%Y-%m-%d %H:%i:%s' ) AS "createdTime"
|
|
FROM
|
|
project
|
|
WHERE
|
|
DEL_FLAG = '0'
|
|
AND ORIGIN = 'work_event'
|
|
AND AGENCY_ID = #{agencyId}
|
|
<if test="staffId != null and staffId != ''">
|
|
AND CREATED_BY = #{staffId}
|
|
</if>
|
|
<if test="startTime != null and startTime != ''">
|
|
AND DATE_FORMAT( CREATED_TIME, '%Y%m%d' ) >= #{startTime}
|
|
</if>
|
|
<if test="endTime != null and endTime != ''">
|
|
AND DATE_FORMAT( CREATED_TIME, '%Y%m%d' ) <= #{endTime}
|
|
</if>
|
|
ORDER BY CREATED_TIME DESC
|
|
</select>
|
|
<select id="getProjectListForWorkMinutes" resultType="com.epmet.entity.ProjectEntity">
|
|
SELECT
|
|
a.ID,
|
|
a.`STATUS`,
|
|
a.CREATED_TIME,
|
|
b.CREATED_TIME AS "updatedTime"
|
|
FROM
|
|
project a
|
|
LEFT JOIN project_process b ON a.ID = b.PROJECT_ID
|
|
AND b.OPERATION = 'close'
|
|
WHERE
|
|
a.DEL_FLAG = '0'
|
|
<if test="customerId != null and customerId != ''">
|
|
AND a.CUSTOMER_ID = #{customerId}
|
|
</if>
|
|
<if test="projectId != null and projectId != ''">
|
|
AND a.ID = #{projectId}
|
|
</if>
|
|
<if test="status != null and status != ''">
|
|
AND a.`STATUS` = #{status}
|
|
</if>
|
|
</select>
|
|
|
|
<!-- 查询网格下群众直报处理中的个数 -->
|
|
<select id="selectEventStatus" resultType="java.lang.Integer">
|
|
SELECT
|
|
COUNT( ID )
|
|
FROM resi_event
|
|
WHERE DEL_FLAG = '0'
|
|
AND `STATUS` = 'processing'
|
|
AND audit_status = 'auto_passed'
|
|
AND GRID_ID = #{gridId}
|
|
</select>
|
|
<select id="selectPendListByUserIds" resultType="com.epmet.dto.ProjectDTO">
|
|
SELECT distinct
|
|
p.ID,
|
|
p.TITLE,
|
|
p.CREATED_TIME,
|
|
psp.CREATED_TIME AS UPDATED_TIME
|
|
FROM project p
|
|
INNER JOIN (SELECT
|
|
ps.PROJECT_ID,
|
|
MAX(ps.CREATED_TIME) AS CREATED_TIME
|
|
FROM project_staff ps
|
|
WHERE ps.DEL_FLAG = '0'
|
|
AND ps.IS_HANDLE = 'unhandled'
|
|
AND ps.STAFF_ID IN (
|
|
<foreach collection="userIds" item="userId" separator=",">
|
|
#{userId}
|
|
</foreach>
|
|
)
|
|
GROUP BY ps.PROJECT_ID) psp ON p.ID = psp.PROJECT_ID
|
|
WHERE p.DEL_FLAG = '0'
|
|
AND p.status = 'pending'
|
|
ORDER BY psp.created_time, p.created_time ASC<!-- 先按滞留时间降序再按创建时间升序 -->
|
|
</select>
|
|
|
|
<!-- -->
|
|
<select id="getProjectManageList" resultType="com.epmet.dto.result.ProjectManageListResultDTO">
|
|
SELECT
|
|
p.TITLE,
|
|
p.GRID_ID,
|
|
(CASE WHEN p.STATUS = 'closed' THEN '已结案' ELSE '未结案' END) AS statusValue,
|
|
p.STATUS,
|
|
p.CREATED_TIME AS shiftProjectTime,
|
|
ps.IS_HANDLE,
|
|
ps.CREATED_TIME AS updatedTime,
|
|
t.*
|
|
FROM
|
|
(SELECT
|
|
DISTINCT t.PROJECT_ID,
|
|
t.INTERNAL_REMARK,
|
|
t.projectScheme
|
|
FROM (
|
|
(SELECT
|
|
DISTINCT pp.PROJECT_ID,
|
|
pp.INTERNAL_REMARK,
|
|
pp.PUBLIC_REPLY AS projectScheme
|
|
FROM project_process pp
|
|
WHERE DEL_FLAG = '0'
|
|
AND pp.STAFF_ID = #{userId}
|
|
AND pp.ORG_ID_PATH LIKE CONCAT('%',#{agencyId})
|
|
ORDER BY pp.CREATED_TIME DESC)
|
|
UNION ALL
|
|
(SELECT
|
|
DISTINCT ps.PROJECT_ID ,
|
|
pp.INTERNAL_REMARK,
|
|
pp.PUBLIC_REPLY AS projectScheme
|
|
FROM project_staff ps
|
|
INNER JOIN project_process pp ON pp.PROJECT_ID = ps.PROJECT_ID AND pp.DEL_FLAG = '0'
|
|
WHERE ps.DEL_FLAG = '0'
|
|
AND ps.ORG_ID_PATH LIKE CONCAT('%',#{agencyId})
|
|
AND ps.STAFF_ID = #{userId}
|
|
ORDER BY pp.CREATED_TIME DESC) )t)t
|
|
INNER JOIN project p ON p.ID = t.PROJECT_ID AND p.DEL_FLAG = '0'
|
|
LEFT JOIN project_staff ps ON ps.PROJECT_ID = t.PROJECT_ID AND ps.DEL_FLAG = '0'
|
|
WHERE 1=1
|
|
<if test='null != title and title != "" '>
|
|
AND p.TITLE LIKE CONCAT('%',#{title},'%')
|
|
</if>
|
|
<if test='null != startDate and startDate != "" '>
|
|
AND DATE_FORMAT(p.CREATED_TIME,'%Y%m%d') >= #{startDate}
|
|
</if>
|
|
<if test='null != endDate and endDate != "" '>
|
|
AND DATE_FORMAT(p.CREATED_TIME,'%Y%m%d') <![CDATA[ <= ]]> #{endDate}
|
|
</if>
|
|
<if test='null != status and status != "" and status != "all" '>
|
|
AND p.`STATUS` = #{status}
|
|
</if>
|
|
GROUP BY t.PROJECT_ID
|
|
ORDER BY p.CREATED_TIME DESC
|
|
</select>
|
|
|
|
<resultMap id="OrgProjectListMap" type="com.epmet.dto.result.OrgProjectListResultDTO">
|
|
<id property="projectId" column="id" />
|
|
<id property="agencyId" column="agency_id" />
|
|
<result property="origin" column="origin"/>
|
|
<result property="title" column="title"/>
|
|
<result property="gridId" column="grid_id"/>
|
|
<result property="address" column="locate_address"/>
|
|
<result property="staffId" column="created_by"/>
|
|
<result property="createdTime" column="created_time"></result>
|
|
<result property="backGround" column="back_ground"></result>
|
|
<result property="status" column="status"></result>
|
|
<result property="statusValue" column="statusValue"></result>
|
|
<result property="firstId" column="category_pids"></result>
|
|
<result property="secondId" column="category_id"></result>
|
|
<result property="publicReply" column="public_reply"></result>
|
|
<result property="endTime" column="end_time"></result>
|
|
<result property="departmentName" column="department_name"></result>
|
|
<result property="createPublicReply" column="public_reply"></result>
|
|
<collection property="urlList" ofType="com.epmet.dto.form.FileDTO" column="id" select="getIndexExplainTreeByPid">
|
|
</collection>
|
|
</resultMap>
|
|
<select id="orgProjectList" resultMap="OrgProjectListMap">
|
|
SELECT
|
|
p.id,
|
|
p.agency_id,
|
|
( CASE WHEN p.origin = 'issue' THEN '议题上报' WHEN p.origin = 'ic_event' THEN '居民上报' WHEN p.origin = 'work_event' THEN '巡查上报' WHEN p.origin = 'agency' THEN '网格上报' ELSE '' END ) AS origin,
|
|
p.title,
|
|
p.grid_id,
|
|
p.locate_address,
|
|
p.created_by,
|
|
DATE_FORMAT(p.created_time, '%Y-%m-%d %H:%i:%s') AS created_time,
|
|
p.back_ground,
|
|
( CASE WHEN p.`STATUS` = 'pending' THEN '处理中' WHEN p.`STATUS` = 'closed' THEN '已结案' ELSE '' END ) AS status,
|
|
p.`status` AS statusValue,
|
|
( CASE WHEN p.CLOSED_STATUS = 'resolved' THEN '已解决' WHEN p.CLOSED_STATUS = 'unresolved' THEN '无需解决' ELSE '' END ) AS closedStatus,
|
|
p.CLOSED_STATUS AS closedStatusValue,
|
|
pc.category_pids,
|
|
pc.category_id,
|
|
pp.public_reply,
|
|
DATE_FORMAT(pp.end_time, '%Y-%m-%d %H:%i:%s') AS end_time,
|
|
pp.department_name,
|
|
ppc.public_reply
|
|
FROM
|
|
project p
|
|
<!-- 项目分类现在是只能选一个二类,查询只查一个分类数据 -->
|
|
INNER JOIN (
|
|
select PROJECT_ID,category_pids,category_id
|
|
from project_category
|
|
where del_flag = '0' and customer_id = #{customerId}
|
|
group by project_id
|
|
ORDER BY created_time desc
|
|
)pc ON p.id = pc.project_id
|
|
<if test="(firstIdList != null and firstIdList.size() > 0) and (secondIdList == null or secondIdList.size() == 0)"><!-- 一类查询条件 -->
|
|
<foreach collection="firstIdList" item="firstId" open="AND pc.category_pids IN (" separator="," close=")">
|
|
#{firstId}
|
|
</foreach>
|
|
</if>
|
|
<if test="(secondIdList != null and secondIdList.size() > 0) and (firstIdList == null or firstIdList.size() == 0)"><!-- 二类查询条件 -->
|
|
<foreach collection="secondIdList" item="secondId" open="AND pc.category_id IN (" separator="," close=")">
|
|
#{secondId}
|
|
</foreach>
|
|
</if>
|
|
<if test="(secondIdList != null and secondIdList.size() > 0) and (firstIdList != null and firstIdList.size() > 0)"><!-- 二类查询条件 -->
|
|
<foreach collection="firstIdList" item="firstId" open="AND (pc.CATEGORY_PIDS IN (" separator="," close=")">
|
|
#{firstId}
|
|
</foreach>
|
|
<foreach collection="secondIdList" item="secondId" open="OR pc.CATEGORY_ID IN (" separator="," close="))">
|
|
#{secondId}
|
|
</foreach>
|
|
</if>
|
|
LEFT JOIN project_process pp ON p.id = pp.project_id AND pp.operation = 'close'
|
|
INNER JOIN project_process ppc ON p.id = ppc.project_id AND ppc.operation = 'created'
|
|
<if test="staffName != null and staffName != ''"><!-- 上报人姓名对应查询条件,上报人就是对应的创建节点的人 -->
|
|
AND ppc.staff_name like concat('%', #{staffName}, '%')
|
|
</if>
|
|
<if test="staffId != null and staffId != ''"><!-- 处置选项对应查询条件,查自己涉及要干的活的项目 -->
|
|
INNER JOIN(SELECT DISTINCT PROJECT_ID FROM project_staff WHERE del_flag = '0' AND staff_id = #{staffId} ) ps ON p.id = ps.project_id
|
|
</if>
|
|
WHERE
|
|
p.del_flag = '0'
|
|
AND p.customer_id = #{customerId}
|
|
<if test="orgType != null and orgType != ''"><!-- 组织/网格对应查询条件 -->
|
|
<choose>
|
|
<when test="orgType == 'agency'">
|
|
AND p.org_id_path like concat('%', #{orgId}, '%')
|
|
</when>
|
|
<when test="orgType == 'grid'">
|
|
AND p.grid_id = #{orgId}
|
|
</when>
|
|
</choose>
|
|
</if>
|
|
<if test="origin != null and origin != ''">
|
|
AND p.origin = #{origin}
|
|
</if>
|
|
<if test="staffIds != null and staffIds.size() > 0"><!-- 上报人手机号对应查询条件 -->
|
|
<foreach collection="staffIds" item="createdId" open="AND p.created_by IN (" separator="," close=")">
|
|
#{createdId}
|
|
</foreach>
|
|
</if>
|
|
<if test="backGround != null and backGround != ''">
|
|
AND p.back_ground like concat('%', #{backGround}, '%')
|
|
</if>
|
|
<if test="status != null and status != ''">
|
|
AND p.status = #{status}
|
|
</if>
|
|
<if test=" null != startTime and startTime != '' ">
|
|
AND p.created_time <![CDATA[ >= ]]> #{startTime}
|
|
</if>
|
|
<if test="null != endTime and endTime != '' ">
|
|
AND p.created_time <![CDATA[ <= ]]> #{endTime}
|
|
</if>
|
|
<if test="closedStatus != null and closedStatus != ''">
|
|
AND p.CLOSED_STATUS = #{closedStatus}
|
|
</if>
|
|
</select>
|
|
<select id="getIndexExplainTreeByPid" resultType="com.epmet.dto.form.FileDTO"><!-- 项目创建节点的图片附件 -->
|
|
SELECT
|
|
ppa.attachment_url AS url
|
|
FROM
|
|
project_process pp
|
|
INNER JOIN project_process_attachment ppa ON pp.id = ppa.process_id AND ppa.attachment_type = 'image' AND ppa.del_flag = '0'
|
|
WHERE
|
|
pp.del_flag = '0'
|
|
and pp.operation IN('created', 'close')
|
|
AND pp.project_id = #{projectId}
|
|
ORDER BY
|
|
pp.created_time ASC, ppa.created_time ASC
|
|
</select>
|
|
|
|
</mapper>
|