<?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.panzhihua.service_community.dao.ComFmsServiceDAO">
|
|
<resultMap type="com.panzhihua.service_community.entity.ComFmsService" id="ComFmsServiceMap">
|
<result property="id" column="id" jdbcType="INTEGER"/>
|
<result property="userName" column="user_name" jdbcType="VARCHAR"/>
|
<result property="userId" column="user_id" jdbcType="INTEGER"/>
|
<result property="phone" column="phone" jdbcType="VARCHAR"/>
|
<result property="serviceContent" column="service_content" jdbcType="VARCHAR"/>
|
<result property="serviceImage" column="service_image" jdbcType="VARCHAR"/>
|
<result property="approvalContent" column="approval_content" jdbcType="VARCHAR"/>
|
<result property="approvalAt" column="approval_at" jdbcType="TIMESTAMP"/>
|
<result property="memberId" column="member_id" jdbcType="INTEGER"/>
|
<result property="serviceStatus" column="service_status" jdbcType="INTEGER"/>
|
<result property="serviceAt" column="service_at" jdbcType="TIMESTAMP"/>
|
<result property="createdAt" column="created_at" jdbcType="TIMESTAMP"/>
|
<result property="createdBy" column="created_by" jdbcType="INTEGER"/>
|
<result property="updatedAt" column="updated_at" jdbcType="TIMESTAMP"/>
|
<result property="updatedBy" column="updated_by" jdbcType="INTEGER"/>
|
<result property="communityId" column="community_id" jdbcType="INTEGER"/>
|
</resultMap>
|
|
<!-- 批量插入 -->
|
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
|
insert into smart_life.com_fms_service(user_name, user_id, phone, service_content, service_image, approval_content, approval_at, member_id, service_status, service_at, created_at, created_by, updated_at, updated_by, community_id)
|
values
|
<foreach collection="entities" item="entity" separator=",">
|
(#{entity.userName}, #{entity.userId}, #{entity.phone}, #{entity.serviceContent}, #{entity.serviceImage}, #{entity.approvalContent}, #{entity.approvalAt}, #{entity.memberId}, #{entity.serviceStatus}, #{entity.serviceAt}, #{entity.createdAt}, #{entity.createdBy}, #{entity.updatedAt}, #{entity.updatedBy}, #{entity.communityId})
|
</foreach>
|
</insert>
|
|
|
<select id="getLastId" resultType="String">
|
SELECT LAST_INSERT_ID()
|
</select>
|
|
<insert id="addBracelet" parameterType="com.panzhihua.service_community.entity.ComFmsService" >
|
insert into smart_life.com_fms_service
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="entitie.userName != null">
|
user_name,
|
</if>
|
<if test="entitie.userId != null">
|
user_id,
|
</if>
|
<if test="entitie.phone != null">
|
phone,
|
</if>
|
<if test="entitie.serviceContent != null">
|
service_content,
|
</if>
|
<if test="entitie.serviceImage != null">
|
service_image,
|
</if>
|
<if test="entitie.approvalContent != null">
|
approval_content,
|
</if>
|
<if test="entitie.approvalAt != null">
|
approval_at,
|
</if>
|
<if test="entitie.memberId != null">
|
member_id,
|
</if>
|
<if test="entitie.serviceStatus != null">
|
service_status,
|
</if>
|
<if test="entitie.serviceAt != null">
|
service_at,
|
</if>
|
<if test="entitie.createdBy != null">
|
created_by,
|
</if>
|
<if test="entitie.updatedBy != null">
|
updated_by,
|
</if>
|
<if test="entitie.communityId != null">
|
community_id,
|
</if>
|
created_at
|
</trim>
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<if test="entitie.userName != null">
|
#{entitie.userName},
|
</if>
|
<if test="entitie.userId != null">
|
#{entitie.userId},
|
</if>
|
<if test="entitie.phone != null">
|
#{entitie.phone},
|
</if>
|
<if test="entitie.serviceContent != null">
|
#{entitie.serviceContent},
|
</if>
|
<if test="entitie.serviceImage != null">
|
#{entitie.serviceImage},
|
</if>
|
<if test="entitie.approvalContent != null">
|
#{entitie.approvalContent},
|
</if>
|
<if test="entitie.approvalAt != null">
|
#{entitie.approvalAt},
|
</if>
|
<if test="entitie.memberId != null">
|
#{entitie.memberId},
|
</if>
|
<if test="entitie.serviceStatus != null">
|
#{entitie.serviceStatus},
|
</if>
|
<if test="entitie.serviceAt != null">
|
#{entitie.serviceAt},
|
</if>
|
<if test="entitie.createdBy != null">
|
#{entitie.createdBy},
|
</if>
|
<if test="entitie.updatedBy != null">
|
#{entitie.updatedBy},
|
</if>
|
<if test="entitie.communityId != null">
|
#{entitie.communityId},
|
</if>
|
sysdate()
|
</trim>
|
</insert>
|
|
|
|
<!-- 批量插入或按主键更新 -->
|
<insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
|
insert into smart_life.com_fms_service(user_name, user_id, phone, service_content, service_image, approval_content, approval_at, member_id, service_status, service_at, created_at, created_by, updated_at, updated_by, community_id)
|
values
|
<foreach collection="entities" item="entity" separator=",">
|
(#{entity.userName}, #{entity.userId}, #{entity.phone}, #{entity.serviceContent}, #{entity.serviceImage}, #{entity.approvalContent}, #{entity.approvalAt}, #{entity.memberId}, #{entity.serviceStatus}, #{entity.serviceAt}, #{entity.createdAt}, #{entity.createdBy}, #{entity.updatedAt}, #{entity.updatedBy}, #{entity.communityId})
|
</foreach>
|
on duplicate key update
|
user_name = values(user_name) , user_id = values(user_id) , phone = values(phone) , service_content = values(service_content) , service_image = values(service_image) , approval_content = values(approval_content) , approval_at = values(approval_at) , member_id = values(member_id) , service_status = values(service_status) , service_at = values(service_at) , created_at = values(created_at) , created_by = values(created_by) , updated_at = values(updated_at) , updated_by = values(updated_by) , community_id = values(community_id) </insert>
|
<select id="pageFmsServiceAdmin" resultType="com.panzhihua.common.model.vos.community.fms.ComFmsServiceVO">
|
SELECT t1.id, t1.user_name, t1.phone, t1.created_at, t1.service_content, t2.`name` AS serviceMember, t3.star_level, t1.service_status
|
FROM com_fms_service t1
|
LEFT JOIN com_fms_team_member t2 ON t1.member_id = t2.id
|
LEFT JOIN com_fms_service_evaluations t3 ON t1.id = t3.service_id
|
WHERE t1.community_id = #{adminDTO.communityId}
|
<if test="adminDTO.keyword != null and adminDTO.keyword != """>
|
AND(t1.user_name LIKE CONCAT('%',#{adminDTO.keyword},'%')
|
OR t2.`name` LIKE CONCAT('%',#{adminDTO.keyword},'%')
|
OR t1.service_content LIKE CONCAT('%',#{adminDTO.keyword},'%'))
|
</if>
|
<if test="adminDTO.serviceStatus != null">
|
AND t1.service_status = #{adminDTO.serviceStatus}
|
</if>
|
ORDER BY t1.created_at DESC
|
</select>
|
<select id="detailFmsServiceAdmin"
|
resultType="com.panzhihua.common.model.vos.community.fms.ComFmsServiceVO">
|
SELECT t1.id, t1.user_name, t2.`name` AS realName, t1.phone, t1.service_content, t1.service_image,
|
t1.service_status
|
FROM com_fms_service t1
|
LEFT JOIN sys_user t2 ON t1.user_id = t2.user_id
|
WHERE t1.id = #{serviceId}
|
</select>
|
<select id="statisticsFmsService"
|
resultType="com.panzhihua.common.model.vos.community.fms.FmsServiceTopStatisticsVO">
|
SELECT
|
(SELECT COUNT(id) FROM com_fms_service WHERE community_id = #{communityId} AND service_status = 4) AS completedCount,
|
(SELECT COUNT(id) FROM com_fms_service WHERE community_id = #{communityId} AND service_status = 1) AS unVerifiedCount,
|
(SELECT COUNT(id) FROM com_fms_service WHERE community_id = #{communityId} AND service_status = 2) AS inProgressCount,
|
(SELECT COUNT(id) FROM com_fms_service WHERE community_id = #{communityId} AND service_status = 3) AS unEvaluateCount,
|
(SELECT COUNT(id) FROM com_fms_service WHERE community_id = #{communityId} AND service_status = 5) AS unPassCount
|
</select>
|
<select id="pageFmsServiceAdminApplets"
|
resultType="com.panzhihua.common.model.vos.community.fms.ComFmsServiceVO">
|
SELECT t1.id, t1.service_content, t1.service_image,
|
IF(t2.nick_name IS NULL,IF(t1.user_name IS NULL,'匿名用户',t1.user_name),t2.nick_name) AS nickName, t2.image_url
|
FROM com_fms_service t1
|
LEFT JOIN sys_user t2 ON t1.user_id = t2.user_id
|
WHERE t1.community_id = #{adminDTO.communityId}
|
<if test="adminDTO.status != null and adminDTO.status == 1">
|
AND t1.service_status IN (3,4)
|
</if>
|
<if test="adminDTO.status != null and adminDTO.status == 2">
|
AND t1.service_status = 2
|
</if>
|
ORDER BY t1.created_at DESC
|
</select>
|
<select id="detailFmsServiceApplets"
|
resultType="com.panzhihua.common.model.vos.community.fms.ComFmsServiceVO">
|
SELECT t1.id, t1.service_content, t1.service_image, t1.phone, t1.service_status,
|
t1.created_at, IF(t2.nick_name IS NULL,IF(t1.user_name IS NULL,'匿名用户',t1.user_name),t2.nick_name) AS nickName, t2.image_url
|
FROM com_fms_service t1
|
LEFT JOIN sys_user t2 ON t1.user_id = t2.user_id
|
WHERE t1.id = #{serviceId}
|
</select>
|
<select id="pageMyFmsService" resultType="com.panzhihua.common.model.vos.community.fms.ComFmsServiceVO">
|
SELECT id, service_content, service_image, service_status, created_at
|
FROM com_fms_service WHERE user_id = #{adminDTO.userId} AND community_id = #{adminDTO.communityId}
|
ORDER BY created_at DESC
|
</select>
|
<select id="pageDealFmsService" resultType="com.panzhihua.common.model.vos.community.fms.ComFmsServiceVO">
|
SELECT t1.id, t1.service_content, t1.service_image, t1.service_status, t1.created_at,
|
IF(t2.nick_name IS NULL,IF(t1.user_name IS NULL,'匿名用户',t1.user_name),t2.nick_name) AS nickName, t2.image_url
|
FROM com_fms_service t1
|
LEFT JOIN sys_user t2 ON t1.user_id = t2.user_id
|
WHERE t1.community_id = #{adminDTO.communityId}
|
<if test="adminDTO.dealStatus != null and adminDTO.dealStatus == 1">
|
AND t1.member_id = #{adminDTO.memberId} AND t1.service_status = 2
|
</if>
|
<if test="adminDTO.dealStatus != null and adminDTO.dealStatus == 2">
|
AND t1.service_status = 1
|
</if>
|
<if test="adminDTO.dealStatus != null and adminDTO.dealStatus == 3">
|
AND t1.service_status IN (3,4)
|
</if>
|
ORDER BY t1.created_at DESC
|
</select>
|
<select id="getFmsBaseData"
|
resultType="com.panzhihua.common.model.vos.community.bigscreen.BigScreenFmsStatisticsInfo">
|
SELECT
|
(SELECT COUNT(id) FROM com_fms_team WHERE community_id = #{communityId}) AS teamTotal,
|
(SELECT COUNT(id) FROM com_fms_team_member WHERE community_id = #{communityId}) AS memberTotal,
|
(SELECT COUNT(id) FROM com_fms_service WHERE community_id = #{communityId}) AS serviceTotal,
|
(SELECT COUNT(id) FROM com_fms_service WHERE community_id = #{communityId} AND service_status = 4) AS completeServiceTotal,
|
(SELECT COUNT(id) FROM com_fms_classroom WHERE community_id = #{communityId}) AS classroomTotal,
|
(SELECT COUNT(e.id) FROM `event` AS e LEFT JOIN event_grid_data AS egd ON egd.id = e.grid_id
|
WHERE e.event_category = 1 AND e.event_status = 2 AND e.event_process_status = 2 AND egd.grid_community_id = #{communityId} AND e.event_type = 3) AS adjustTotal,
|
(SELECT COUNT(e.id) FROM `event` AS e LEFT JOIN event_grid_data AS egd ON egd.id = e.grid_id
|
WHERE e.event_category = 1 AND e.event_status = 2 AND e.event_process_status IN(1,2) AND egd.grid_community_id = #{communityId} AND e.event_type = 1) AS controlTotal,
|
(SELECT IF(SUM(scholars) IS NULL,0,SUM(scholars)) FROM com_fms_classroom WHERE community_id = #{communityId}) AS learnTotal,
|
(SELECT COUNT(e.id) FROM `event` AS e LEFT JOIN event_grid_data AS egd ON egd.id = e.grid_id
|
WHERE e.event_category = 1 AND e.event_status = 2 AND e.event_process_status IN(1,2) AND egd.grid_community_id = #{communityId} AND e.event_type = 1 AND e.danger_level > 0) AS fxyhTotal,
|
(SELECT COUNT(e.id) FROM `event` AS e LEFT JOIN event_grid_data AS egd ON egd.id = e.grid_id
|
WHERE e.event_category = 1 AND e.event_status = 2 AND e.event_process_status = 2 AND egd.grid_community_id = #{communityId} AND e.event_type = 1 AND e.danger_level > 0) AS jjyhTotal
|
</select>
|
<select id="retrieveTeamTypeCircleData"
|
resultType="com.panzhihua.common.model.vos.community.fms.ComFmsTeamVO">
|
SELECT
|
t1.id,
|
t1.`name`,
|
t2.`name` AS teamTypeName
|
FROM
|
com_fms_team t1
|
LEFT JOIN com_fms_team_type t2 ON t1.team_type = t2.id
|
WHERE
|
t1.community_id = #{communityId}
|
</select>
|
<select id="retrieveServiceAddPolylineData"
|
resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">
|
SELECT filed, SUM(num) AS num FROM (
|
SELECT DATE_FORMAT( created_at, '%Y-%m' ) AS filed, COUNT(1) AS num
|
FROM com_fms_service
|
WHERE community_id = #{communityId} AND DATE_FORMAT( created_at, '%Y-%m' ) > DATE_FORMAT(date_sub(curdate(), interval 12 month),'%Y-%m'
|
) GROUP BY filed
|
UNION ALL SELECT * FROM
|
(
|
SELECT DATE_FORMAT(curdate(),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 1 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 2 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 3 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 4 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 5 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 6 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 7 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 8 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 9 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 10 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 11 month),'%Y-%m') AS filed, 0 AS num
|
) temT
|
) temp GROUP BY filed ORDER BY filed ASC
|
</select>
|
<select id="retrieveServiceTotalPolylineData"
|
resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">
|
SELECT
|
COUNT( 1 ) AS num
|
FROM
|
com_fms_service
|
WHERE
|
community_id = #{communityId}
|
AND DATE_FORMAT( created_at, '%Y-%m' ) <= #{date}
|
</select>
|
<select id="retrieveAdjustCircleData" resultType="com.panzhihua.common.model.vos.grid.EventVO">
|
SELECT
|
e.id,
|
substring_index( substring_index( e.event_clazz, ',', b.help_topic_id + 1 ), ',',- 1 ) AS event_clazz
|
FROM
|
`event` AS e
|
LEFT JOIN event_grid_data AS egd ON egd.id = e.grid_id
|
JOIN mysql.help_topic b ON b.help_topic_id < ( length( e.event_clazz ) - length( REPLACE ( e.event_clazz, ',', '' ))+ 1 )
|
WHERE
|
e.event_category = 1
|
AND e.event_status = 2
|
AND e.event_process_status = 2
|
AND egd.grid_community_id = #{communityId}
|
AND e.event_type = 3
|
</select>
|
<select id="retrieveAdjustAddPolylineData"
|
resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">
|
SELECT filed, SUM(num) AS num FROM (
|
SELECT DATE_FORMAT( e.create_at, '%Y-%m' ) AS filed, COUNT(1) AS num
|
FROM `event` AS e
|
LEFT JOIN event_grid_data AS egd ON egd.id = e.grid_id
|
WHERE e.event_category = 1
|
AND e.event_status = 2
|
AND e.event_process_status = 2
|
AND egd.grid_community_id = #{communityId}
|
AND e.event_type = 3 AND DATE_FORMAT( e.create_at, '%Y-%m' ) > DATE_FORMAT(date_sub(curdate(), interval 12 month),'%Y-%m'
|
) GROUP BY filed
|
UNION ALL SELECT * FROM
|
(
|
SELECT DATE_FORMAT(curdate(),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 1 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 2 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 3 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 4 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 5 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 6 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 7 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 8 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 9 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 10 month),'%Y-%m') AS filed, 0 AS num union
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 11 month),'%Y-%m') AS filed, 0 AS num
|
) temT
|
) temp GROUP BY filed ORDER BY filed ASC
|
</select>
|
<select id="retrieveAdjustTotalPolylineData"
|
resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">
|
SELECT
|
COUNT( e.id ) AS num
|
FROM `event` AS e
|
LEFT JOIN event_grid_data AS egd ON egd.id = e.grid_id
|
WHERE e.event_category = 1
|
AND e.event_status = 2
|
AND e.event_process_status = 2
|
AND egd.grid_community_id = #{communityId}
|
AND e.event_type = 3
|
AND DATE_FORMAT( e.create_at, '%Y-%m' ) <= #{date}
|
</select>
|
<select id="retrieveControlCircleData" resultType="com.panzhihua.common.model.vos.grid.EventVO">
|
SELECT
|
e.id,
|
substring_index( substring_index( e.event_clazz, ',', b.help_topic_id + 1 ), ',',- 1 ) AS event_clazz
|
FROM
|
`event` AS e
|
LEFT JOIN event_grid_data AS egd ON egd.id = e.grid_id
|
JOIN mysql.help_topic b ON b.help_topic_id < ( length( e.event_clazz ) - length( REPLACE ( e.event_clazz, ',', '' ))+ 1 )
|
WHERE
|
e.event_category = 1
|
AND e.event_status = 2
|
AND e.event_process_status = 2
|
AND egd.grid_community_id = #{communityId}
|
AND e.event_type = 1
|
</select>
|
<select id="pageFmsTeam" resultType="com.panzhihua.common.model.vos.community.fms.ComFmsTeamVO">
|
SELECT
|
t1.id,
|
t1.`name`,
|
t2.`name` AS teamTypeName,
|
COUNT(t3.team_id) AS teamMemberTotal
|
FROM com_fms_team t1
|
LEFT JOIN com_fms_team_type t2 ON t1.team_type = t2.id
|
LEFT JOIN com_fms_team_member_relation t3 ON t1.id = t3.team_id
|
WHERE t1.community_id = #{pageBaseDTO.communityId}
|
GROUP BY t1.id
|
</select>
|
|
</mapper>
|