增加问卷调查展示逻辑
This commit is contained in:
@ -1,27 +1,19 @@
|
||||
package com.ruoyi.dw.controller;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.dw.domain.DwIndexConfig;
|
||||
import com.ruoyi.dw.service.IDwIndexConfigService;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 调查问卷统计展示Controller
|
||||
@ -47,6 +39,15 @@ public class DwIndexConfigController extends BaseController
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取首页的数据展示
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getIndex")
|
||||
public AjaxResult getIndex(){
|
||||
return AjaxResult.success(dwIndexConfigService.getIndex());
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出调查问卷统计展示列表
|
||||
*/
|
||||
|
@ -0,0 +1,23 @@
|
||||
package com.ruoyi.dw.domain.vo;
|
||||
|
||||
public class AnswerCountVo {
|
||||
private String answer;
|
||||
|
||||
private int answerCount;
|
||||
|
||||
public String getAnswer() {
|
||||
return answer;
|
||||
}
|
||||
|
||||
public void setAnswer(String answer) {
|
||||
this.answer = answer;
|
||||
}
|
||||
|
||||
public int getAnswerCount() {
|
||||
return answerCount;
|
||||
}
|
||||
|
||||
public void setAnswerCount(int answerCount) {
|
||||
this.answerCount = answerCount;
|
||||
}
|
||||
}
|
@ -1,7 +1,12 @@
|
||||
package com.ruoyi.dw.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.ruoyi.dw.domain.DwIndexConfig;
|
||||
import com.ruoyi.dw.domain.vo.AnswerCountVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 调查问卷统计展示Mapper接口
|
||||
@ -58,4 +63,11 @@ public interface DwIndexConfigMapper
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDwIndexConfigByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 根据问题id进行统计
|
||||
* @param questionIds
|
||||
* @return
|
||||
*/
|
||||
public List<AnswerCountVo> selectIndex(@Param("questionIds") String[] questionIds, @Param("infoId") Long infoId);
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.ruoyi.dw.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.ruoyi.dw.domain.DwIndexConfig;
|
||||
|
||||
/**
|
||||
@ -58,4 +60,10 @@ public interface IDwIndexConfigService
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDwIndexConfigById(Long id);
|
||||
|
||||
/**
|
||||
* 获取首页的四个展位数据
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> getIndex();
|
||||
}
|
||||
|
@ -1,7 +1,12 @@
|
||||
package com.ruoyi.dw.service.impl;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.dw.domain.vo.AnswerCountVo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.dw.mapper.DwIndexConfigMapper;
|
||||
@ -93,4 +98,18 @@ public class DwIndexConfigServiceImpl implements IDwIndexConfigService
|
||||
{
|
||||
return dwIndexConfigMapper.deleteDwIndexConfigById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getIndex()
|
||||
{
|
||||
List<DwIndexConfig> configs = dwIndexConfigMapper.selectDwIndexConfigList(new DwIndexConfig());
|
||||
Map<String, Object> result = new HashMap<String, Object>();
|
||||
for (DwIndexConfig config: configs){
|
||||
result.put("id", config.getId());
|
||||
result.put("indexType", config.getIndexType());
|
||||
List<AnswerCountVo> list = dwIndexConfigMapper.selectIndex(config.getQuestionId().split(","), config.getInfoId());
|
||||
result.put("data", list);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -88,4 +88,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="selectIndex" resultType="com.ruoyi.dw.domain.vo.AnswerCountVo">
|
||||
select answer, count(0) as answer_count from dw_answer
|
||||
where indo_id = #{infoId}
|
||||
and question_id in
|
||||
<foreach item="questionId" collection="questionIds" open="(" separator="," close=")">
|
||||
#{questionId}
|
||||
</foreach>
|
||||
group by answer
|
||||
</select>
|
||||
</mapper>
|
Reference in New Issue
Block a user