101captain
2021-09-22 1775bb71f952106c58657cf02891cbe2a286c8f8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
package com.panzhihua.service_community.dao;
 
import java.util.List;
 
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
 
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.panzhihua.common.model.dtos.community.PageQuestnaireDTO;
import com.panzhihua.common.model.dtos.community.questnaire.StatisticsSummaryDTO;
import com.panzhihua.common.model.vos.community.ComActQuestnaireAppVO;
import com.panzhihua.common.model.vos.community.questnaire.*;
import com.panzhihua.service_community.model.dos.ComActQuestnaireDO;
 
/**
 * @Author: llming
 * @Description: 调查问卷 问卷表
 */
@Mapper
public interface ComActQuestnaireDAO extends BaseMapper<ComActQuestnaireDO> {
    @Select("<script> " + "SELECT " + " caq.id, " + " caq.project_key, " + " caq.title, " + " caq.state, "
        + " caq.for_masses, " + " caq.for_party, " + " caq.for_volunteer, " + " caq.join_count, " + " caq.remark, "
        + " caq.is_cover, " + " caq.is_force, " + " caq.create_at, " + " caq.count, "
        + " if(caqua.id is not null,1,2) isAnswer, " + " caq.view_num  " + "FROM " + " com_act_questnaire as caq "
        + " left join com_act_questnaire_user_answer as caqua on caqua.questnaire_id = caq.id and caqua.user_id = #{pageQuestnaireDTO.userId} "
        + "WHERE " + " caq.state IN ( 2, 3 )  "
        + " AND caq.community_id = #{pageQuestnaireDTO.communityId}  and caq.is_hide = 0 " + "ORDER BY "
        + " caq.state ASC, " + " isAnswer ASC, " + " caq.create_at DESC" + "</script>")
    IPage<QuestnaireListVo> selectPageList(Page page, @Param("pageQuestnaireDTO") PageQuestnaireDTO pageQuestnaireDTO);
 
    @Select("<script>"
        + "select id,title,view_num,join_count,for_masses,for_party,for_volunteer,adver_position_top,adver_position_popup"
        + ",adver_position_application,create_at,start_time,end_time,publish_time,state,is_cover,project_key,count"
        + " from com_act_questnaire as caq where community_id = #{pageQuestnaireDTO.communityId} and is_hide = 0 "
        + "<if test='pageQuestnaireDTO.identity != null and pageQuestnaireDTO.identity == 1'>"
        + " and caq.for_masses = 1 " + " </if> "
        + "<if test='pageQuestnaireDTO.identity != null and pageQuestnaireDTO.identity == 2'>"
        + " and caq.for_party = 1 " + " </if> "
        + "<if test='pageQuestnaireDTO.identity != null and pageQuestnaireDTO.identity == 3'>"
        + " and caq.for_volunteer = 1 " + " </if> "
        + "<if test='pageQuestnaireDTO.advertPosition != null and pageQuestnaireDTO.advertPosition == 1'>"
        + " and caq.adver_position_popup = 1 " + " </if> "
        + "<if test='pageQuestnaireDTO.advertPosition != null and pageQuestnaireDTO.advertPosition == 2'>"
        + " and caq.adver_position_top = 1 " + " </if> "
        + "<if test='pageQuestnaireDTO.advertPosition != null and pageQuestnaireDTO.advertPosition == 3'>"
        + " and caq.adver_position_application = 1 " + " </if> "
        + "<if test='pageQuestnaireDTO.states != null and pageQuestnaireDTO.states.size > 0 '>" + " and caq.state in "
        + "<foreach item=\"item\" collection=\"pageQuestnaireDTO.states\" separator=\",\" open=\"(\" close=\")\" index=\"\"> \n"
        + "#{item}\n" + "</foreach>\n" + " </if> "
        + "<if test='pageQuestnaireDTO.startTime != null and pageQuestnaireDTO.startTime != &quot;&quot;'>"
        + " and caq.publish_time  <![CDATA[ >= ]]> #{pageQuestnaireDTO.startTime}" + " </if> "
        + "<if test='pageQuestnaireDTO.endTime != null and pageQuestnaireDTO.endTime != &quot;&quot;'>"
        + " and caq.publish_time  <![CDATA[ <= ]]> #{pageQuestnaireDTO.endTime}" + " </if> "
        + "<if test='pageQuestnaireDTO.title != null and pageQuestnaireDTO.title != &quot;&quot;'>"
        + " and caq.title like concat (#{pageQuestnaireDTO.title},'%')" + " </if> " + " order by caq.create_at DESC "
        + "</script>")
    IPage<QuestnaireListAdminVO> selectPageListAdmin(Page page,
        @Param("pageQuestnaireDTO") PageQuestnaireDTO pageQuestnaireDTO);
 
    @Select("select count(id) from com_act_questnaire_user where user_id = #{userId} and questnaire_id = #{questnaireId}")
    Integer getNoRemindCount(@Param("userId") Long userId, @Param("questnaireId") Long questnaireId);
 
    @Select("SELECT " + " id, " + " title, " + " remark, " + " is_cover, " + " for_masses, " + " for_party, "
        + " for_volunteer, " + " is_force, " + " adver_position_popup, " + " adver_position_top, "
        + " adver_position_application, " + " project_key  " + "FROM " + " com_act_questnaire  " + "WHERE "
        + " end_time >= now()  " + " AND now() >= start_time  " + " and community_id = #{communityId} "
        + " and adver_position_top = 1 " + " and state = 2")
    List<ComActQuestnaireAppVO> getIndexTopQuestnaireList(@Param("communityId") Long communityId);
 
    @Select("SELECT " + " id, " + " title, " + " remark, " + " for_masses, " + " for_party, " + " for_volunteer, "
        + " is_cover, " + " is_force, " + " adver_position_popup, " + " adver_position_top, "
        + " adver_position_application, " + " project_key  " + "FROM " + " com_act_questnaire  " + "WHERE "
        + " end_time >= now()  " + " AND now() >= start_time  " + " and community_id = #{communityId} "
        + " and adver_position_application = 1 " + " and state = 2")
    List<ComActQuestnaireAppVO> getIndexApplicationQuestnaireList(@Param("communityId") Long communityId);
 
    Integer getAdvPopupCount(@Param("communityId") Long communityId, @Param("startTime") String startTime,
        @Param("endTime") String endTime, @Param("id") Long id);
 
    void deleteQuesSubAll(@Param("queId") Long queId);
 
    QuestnaireDetailAdminVO getQuesDetailAdmin(@Param("queId") Long queId);
 
    /**
     * 小程序-问卷调查详情
     * 
     * @param userId
     *            用户id
     * @param questId
     *            问卷id
     * @return 问卷调查详情
     */
    QuestnaireDetailAdminVO getQuesDetail(@Param("questId") Long questId, @Param("userId") Long userId);
 
    /**
     * 问卷调查统计汇总
     * 
     * @param summaryDTO
     *            请求参数
     * @return 统计汇总
     */
    IPage<QuestnaireStatisticsSummaryAdminVO> getStatisticsSummaryAdmin(Page page,
        @Param("summaryDTO") StatisticsSummaryDTO summaryDTO);
 
    /**
     * 问卷调查统计汇总导出数据查询
     * 
     * @param questId
     *            调查问卷id
     * @return 调查统计汇总导出数据
     */
    List<QuestnaireStatisticsSummaryExcelAdminVO> getStatisticsSummaryExcelAdmin(@Param("questId") Long questId);
 
    /**
     * 问卷调查统计汇总表头统计
     * 
     * @param questId
     *            调查问卷id
     * @return 问卷调查统计汇总表头统计数据
     */
    QuestnaireStatisticsSummaryHeaderAdminVO statisticsSummaryHeader(@Param("questId") Long questId,
        @Param("communityId") Long communityId);
 
    void addNoNotice(@Param("questId") Long questId, @Param("userId") Long userId);
}