|
|
|
@ -1,28 +1,36 @@
|
|
|
|
|
package com.controller;
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.text.ParseException;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.text.ParseException;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.Calendar;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.Iterator;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
|
|
import com.utils.ValidatorUtils;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.format.annotation.DateTimeFormat;
|
|
|
|
|
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.RequestParam;
|
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.mapper.Wrapper;
|
|
|
|
|
import com.annotation.IgnoreAuth;
|
|
|
|
|
|
|
|
|
|
import com.entity.WenjuandafuEntity;
|
|
|
|
|
import com.entity.view.WenjuandafuView;
|
|
|
|
|
|
|
|
|
|
import com.service.WenjuandafuService;
|
|
|
|
|
import com.service.TokenService;
|
|
|
|
|
import com.utils.PageUtils;
|
|
|
|
@ -32,7 +40,11 @@ import com.utils.MPUtil;
|
|
|
|
|
import com.utils.CommonUtil;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 问卷答复控制器,提供问卷答复的增删改查接口。
|
|
|
|
|
* 问卷答复
|
|
|
|
|
* 后端接口
|
|
|
|
|
* @author
|
|
|
|
|
* @email
|
|
|
|
|
* @date 2023-02-21 09:46:06
|
|
|
|
|
*/
|
|
|
|
|
@RestController
|
|
|
|
|
@RequestMapping("/wenjuandafu")
|
|
|
|
@ -40,57 +52,66 @@ public class WenjuandafuController {
|
|
|
|
|
@Autowired
|
|
|
|
|
private WenjuandafuService wenjuandafuService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取问卷答复列表(分页)
|
|
|
|
|
* @param params 请求参数
|
|
|
|
|
* @param wenjuandafu 查询条件
|
|
|
|
|
* @param request HTTP请求对象
|
|
|
|
|
* @return 包含问卷答复列表的响应结果
|
|
|
|
|
* 后端列表
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/page")
|
|
|
|
|
public R page(@RequestParam Map<String, Object> params, WenjuandafuEntity wenjuandafu, HttpServletRequest request){
|
|
|
|
|
String tableName = request.getSession().getAttribute("tableName").toString();
|
|
|
|
|
if(tableName.equals("yonghu")) {
|
|
|
|
|
wenjuandafu.setZhanghao((String)request.getSession().getAttribute("username"));
|
|
|
|
|
}
|
|
|
|
|
public R page(@RequestParam Map<String, Object> params,WenjuandafuEntity wenjuandafu,
|
|
|
|
|
HttpServletRequest request){
|
|
|
|
|
|
|
|
|
|
String tableName = request.getSession().getAttribute("tableName").toString();
|
|
|
|
|
if(tableName.equals("yonghu")) {
|
|
|
|
|
wenjuandafu.setZhanghao((String)request.getSession().getAttribute("username"));
|
|
|
|
|
}
|
|
|
|
|
EntityWrapper<WenjuandafuEntity> ew = new EntityWrapper<WenjuandafuEntity>();
|
|
|
|
|
PageUtils page = wenjuandafuService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, wenjuandafu), params), params));
|
|
|
|
|
request.setAttribute("data", page);
|
|
|
|
|
|
|
|
|
|
PageUtils page = wenjuandafuService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, wenjuandafu), params), params));
|
|
|
|
|
request.setAttribute("data", page);
|
|
|
|
|
return R.ok().put("data", page);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取问卷答复列表(不分页)
|
|
|
|
|
* @param params 请求参数
|
|
|
|
|
* @param wenjuandafu 查询条件
|
|
|
|
|
* @param request HTTP请求对象
|
|
|
|
|
* @return 包含问卷答复列表的响应结果
|
|
|
|
|
* 前端列表
|
|
|
|
|
*/
|
|
|
|
|
@IgnoreAuth
|
|
|
|
|
@IgnoreAuth
|
|
|
|
|
@RequestMapping("/list")
|
|
|
|
|
public R list(@RequestParam Map<String, Object> params, WenjuandafuEntity wenjuandafu, HttpServletRequest request){
|
|
|
|
|
public R list(@RequestParam Map<String, Object> params,WenjuandafuEntity wenjuandafu,
|
|
|
|
|
HttpServletRequest request){
|
|
|
|
|
EntityWrapper<WenjuandafuEntity> ew = new EntityWrapper<WenjuandafuEntity>();
|
|
|
|
|
PageUtils page = wenjuandafuService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, wenjuandafu), params), params));
|
|
|
|
|
request.setAttribute("data", page);
|
|
|
|
|
|
|
|
|
|
PageUtils page = wenjuandafuService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, wenjuandafu), params), params));
|
|
|
|
|
request.setAttribute("data", page);
|
|
|
|
|
return R.ok().put("data", page);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取所有问卷答复列表
|
|
|
|
|
* @param wenjuandafu 查询条件
|
|
|
|
|
* @return 包含问卷答复列表的响应结果
|
|
|
|
|
/**
|
|
|
|
|
* 列表
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/lists")
|
|
|
|
|
public R lists(WenjuandafuEntity wenjuandafu){
|
|
|
|
|
EntityWrapper<WenjuandafuEntity> ew = new EntityWrapper<WenjuandafuEntity>();
|
|
|
|
|
ew.allEq(MPUtil.allEQMapPre( wenjuandafu, "wenjuandafu"));
|
|
|
|
|
public R list( WenjuandafuEntity wenjuandafu){
|
|
|
|
|
EntityWrapper<WenjuandafuEntity> ew = new EntityWrapper<WenjuandafuEntity>();
|
|
|
|
|
ew.allEq(MPUtil.allEQMapPre( wenjuandafu, "wenjuandafu"));
|
|
|
|
|
return R.ok().put("data", wenjuandafuService.selectListView(ew));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/query")
|
|
|
|
|
public R query(WenjuandafuEntity wenjuandafu){
|
|
|
|
|
EntityWrapper< WenjuandafuEntity> ew = new EntityWrapper< WenjuandafuEntity>();
|
|
|
|
|
ew.allEq(MPUtil.allEQMapPre( wenjuandafu, "wenjuandafu"));
|
|
|
|
|
WenjuandafuView wenjuandafuView = wenjuandafuService.selectView(ew);
|
|
|
|
|
return R.ok("查询问卷答复成功").put("data", wenjuandafuView);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询单个问卷答复信息
|
|
|
|
|
* @param id 问卷答复ID
|
|
|
|
|
* @return 包含问卷答复信息的响应结果
|
|
|
|
|
* 后端详情
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/info/{id}")
|
|
|
|
|
public R info(@PathVariable("id") Long id){
|
|
|
|
@ -99,126 +120,112 @@ public class WenjuandafuController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 前端详情页面显示问卷答复信息
|
|
|
|
|
* @param id 问卷答复ID
|
|
|
|
|
* @return 包含问卷答复信息的响应结果
|
|
|
|
|
* 前端详情
|
|
|
|
|
*/
|
|
|
|
|
@IgnoreAuth
|
|
|
|
|
@IgnoreAuth
|
|
|
|
|
@RequestMapping("/detail/{id}")
|
|
|
|
|
public R detail(@PathVariable("id") Long id){
|
|
|
|
|
WenjuandafuEntity wenjuandafu = wenjuandafuService.selectById(id);
|
|
|
|
|
return R.ok().put("data", wenjuandafu);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 保存问卷答复信息
|
|
|
|
|
* @param wenjuandafu 问卷答复实体对象
|
|
|
|
|
* @param request HTTP请求对象
|
|
|
|
|
* @return 操作结果响应
|
|
|
|
|
* 后端保存
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/save")
|
|
|
|
|
public R save(@RequestBody WenjuandafuEntity wenjuandafu, HttpServletRequest request){
|
|
|
|
|
wenjuandafu.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
|
|
|
|
|
//ValidatorUtils.validateEntity(wenjuandafu); // 验证实体对象(注释掉)
|
|
|
|
|
wenjuandafu.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
|
|
|
|
|
//ValidatorUtils.validateEntity(wenjuandafu);
|
|
|
|
|
|
|
|
|
|
wenjuandafuService.insert(wenjuandafu);
|
|
|
|
|
return R.ok();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 前端保存问卷答复信息
|
|
|
|
|
* @param wenjuandafu 问卷答复实体对象
|
|
|
|
|
* @param request HTTP请求对象
|
|
|
|
|
* @return 操作结果响应
|
|
|
|
|
* 前端保存
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/add")
|
|
|
|
|
public R add(@RequestBody WenjuandafuEntity wenjuandafu, HttpServletRequest request){
|
|
|
|
|
wenjuandafu.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
|
|
|
|
|
//ValidatorUtils.validateEntity(wenjuandafu); // 验证实体对象(注释掉)
|
|
|
|
|
wenjuandafu.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
|
|
|
|
|
//ValidatorUtils.validateEntity(wenjuandafu);
|
|
|
|
|
|
|
|
|
|
wenjuandafuService.insert(wenjuandafu);
|
|
|
|
|
return R.ok();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 修改问卷答复信息
|
|
|
|
|
* @param wenjuandafu 问卷答复实体对象
|
|
|
|
|
* @param request HTTP请求对象
|
|
|
|
|
* @return 操作结果响应
|
|
|
|
|
* 修改
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/update")
|
|
|
|
|
@Transactional
|
|
|
|
|
public R update(@RequestBody WenjuandafuEntity wenjuandafu, HttpServletRequest request){
|
|
|
|
|
//ValidatorUtils.validateEntity(wenjuandafu); // 验证实体对象(注释掉)
|
|
|
|
|
wenjuandafuService.updateById(wenjuandafu); //更新全部字段
|
|
|
|
|
//ValidatorUtils.validateEntity(wenjuandafu);
|
|
|
|
|
wenjuandafuService.updateById(wenjuandafu);//全部更新
|
|
|
|
|
return R.ok();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 删除问卷答复信息
|
|
|
|
|
* @param ids 要删除的问卷答复ID数组
|
|
|
|
|
* @return 操作结果响应
|
|
|
|
|
* 删除
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/delete")
|
|
|
|
|
public R delete(@RequestBody Long[] ids){
|
|
|
|
|
wenjuandafuService.deleteBatchIds(Arrays.asList(ids));
|
|
|
|
|
return R.ok();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 提醒接口
|
|
|
|
|
* @param columnName 列名
|
|
|
|
|
* @param type 类型(2:日期范围)
|
|
|
|
|
* @param request HTTP请求对象
|
|
|
|
|
* @param map 请求参数
|
|
|
|
|
* @return 符合条件的记录数响应
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/remind/{columnName}/{type}")
|
|
|
|
|
public R remindCount(@PathVariable("columnName") String columnName, @PathVariable("type") String type, HttpServletRequest request, @RequestParam Map<String, Object> map) {
|
|
|
|
|
map.put("column", columnName);
|
|
|
|
|
map.put("type", type);
|
|
|
|
|
|
|
|
|
|
if(type.equals("2")) { // 如果类型是日期范围
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
Calendar c = Calendar.getInstance(); // 获取当前日期实例
|
|
|
|
|
//初始话开始和结束日期
|
|
|
|
|
Date remindStartDate = null;
|
|
|
|
|
Date remindEndDate = null;
|
|
|
|
|
|
|
|
|
|
if(map.get("remindstart") != null) { // 如果请求参数中包含开始日期
|
|
|
|
|
Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); // 获取开始日期天数差值
|
|
|
|
|
c.setTime(new Date()); // 设置当前日期时间
|
|
|
|
|
c.add(Calendar.DAY_OF_MONTH, remindStart); // 根据天数差值计算开始日期
|
|
|
|
|
remindStartDate = c.getTime();
|
|
|
|
|
map.put("remindstart", sdf.format(remindStartDate)); // 将开始日期格式化并放入请求参数中
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(map.get("remindend") != null) { // 如果请求参数中包含结束日期
|
|
|
|
|
Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); // 获取结束日期天数差值
|
|
|
|
|
c.setTime(new Date()); // 设置当前日期时间
|
|
|
|
|
c.add(Calendar.DAY_OF_MONTH, remindEnd);
|
|
|
|
|
remindEndDate = c.getTime(); // 获取计算后的结束日期
|
|
|
|
|
map.put("remindend", sdf.format(remindEndDate)); // 将结束日期格式化并放入请求参数中
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String tableName = request.getSession().getAttribute("tableName").toString(); // 获取表名
|
|
|
|
|
if(tableName.equals("yonghu")) { // 如果表名是用户表
|
|
|
|
|
map.put("zhanghao", (String)request.getSession().getAttribute("username")); // 添加用户名到请求参数中作为过滤条件
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Wrapper<WenjuandafuEntity> wrapper = new EntityWrapper<WenjuandafuEntity>(); // 创建查询包装器实例
|
|
|
|
|
|
|
|
|
|
if(map.get("remindstart") != null) {
|
|
|
|
|
wrapper.ge(columnName, map.get("remindstart")); // 添加大于等于开始日期的条件到查询包装器中
|
|
|
|
|
}
|
|
|
|
|
if(map.get("remindend") != null) {
|
|
|
|
|
wrapper.le(columnName, map.get("remindend"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int count = wenjuandafuService.selectCount(wrapper); // 根据查询包装器统计符合条件的记录数
|
|
|
|
|
return R.ok().put("count", count); // 返回符合条件的记录数响应
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@RequestMapping("/remind/{columnName}/{type}")
|
|
|
|
|
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
|
|
|
|
|
@PathVariable("type") String type,@RequestParam Map<String, Object> map) {
|
|
|
|
|
map.put("column", columnName);
|
|
|
|
|
map.put("type", type);
|
|
|
|
|
|
|
|
|
|
if(type.equals("2")) {
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
Calendar c = Calendar.getInstance();
|
|
|
|
|
Date remindStartDate = null;
|
|
|
|
|
Date remindEndDate = null;
|
|
|
|
|
if(map.get("remindstart")!=null) {
|
|
|
|
|
Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
|
|
|
|
|
c.setTime(new Date());
|
|
|
|
|
c.add(Calendar.DAY_OF_MONTH,remindStart);
|
|
|
|
|
remindStartDate = c.getTime();
|
|
|
|
|
map.put("remindstart", sdf.format(remindStartDate));
|
|
|
|
|
}
|
|
|
|
|
if(map.get("remindend")!=null) {
|
|
|
|
|
Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
|
|
|
|
|
c.setTime(new Date());
|
|
|
|
|
c.add(Calendar.DAY_OF_MONTH,remindEnd);
|
|
|
|
|
remindEndDate = c.getTime();
|
|
|
|
|
map.put("remindend", sdf.format(remindEndDate));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Wrapper<WenjuandafuEntity> wrapper = new EntityWrapper<WenjuandafuEntity>();
|
|
|
|
|
if(map.get("remindstart")!=null) {
|
|
|
|
|
wrapper.ge(columnName, map.get("remindstart"));
|
|
|
|
|
}
|
|
|
|
|
if(map.get("remindend")!=null) {
|
|
|
|
|
wrapper.le(columnName, map.get("remindend"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String tableName = request.getSession().getAttribute("tableName").toString();
|
|
|
|
|
if(tableName.equals("yonghu")) {
|
|
|
|
|
wrapper.eq("zhanghao", (String)request.getSession().getAttribute("username"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int count = wenjuandafuService.selectCount(wrapper);
|
|
|
|
|
return R.ok().put("count", count);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -228,136 +235,94 @@ public class WenjuandafuController {
|
|
|
|
|
/**
|
|
|
|
|
* (按值统计)
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/value/{xColumnName}/{yColumnName}")
|
|
|
|
|
public R value(@PathVariable("yColumnName") String yColumnName, @PathVariable("xColumnName") String xColumnName, HttpServletRequest request) {
|
|
|
|
|
// 创建参数映射,用于存储请求中的列名
|
|
|
|
|
Map<String, Object> params = new HashMap<String, Object>();
|
|
|
|
|
params.put("xColumn", xColumnName);
|
|
|
|
|
params.put("yColumn", yColumnName);
|
|
|
|
|
|
|
|
|
|
// 创建实体包装器,用于构建查询条件
|
|
|
|
|
EntityWrapper<WenjuandafuEntity> ew = new EntityWrapper<WenjuandafuEntity>();
|
|
|
|
|
|
|
|
|
|
// 获取当前会话中的表名
|
|
|
|
|
String tableName = request.getSession().getAttribute("tableName").toString();
|
|
|
|
|
|
|
|
|
|
// 如果表名为"yonghu",则添加用户账号作为查询条件
|
|
|
|
|
if (tableName.equals("yonghu")) {
|
|
|
|
|
ew.eq("zhanghao", (String) request.getSession().getAttribute("username"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 调用服务层方法进行数据查询
|
|
|
|
|
List<Map<String, Object>> result = wenjuandafuService.selectValue(params, ew);
|
|
|
|
|
|
|
|
|
|
// 格式化日期对象为字符串
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
for (Map<String, Object> m : result) {
|
|
|
|
|
for (String k : m.keySet()) {
|
|
|
|
|
if (m.get(k) instanceof Date) {
|
|
|
|
|
m.put(k, sdf.format((Date) m.get(k)));
|
|
|
|
|
@RequestMapping("/value/{xColumnName}/{yColumnName}")
|
|
|
|
|
public R value(@PathVariable("yColumnName") String yColumnName, @PathVariable("xColumnName") String xColumnName,HttpServletRequest request) {
|
|
|
|
|
Map<String, Object> params = new HashMap<String, Object>();
|
|
|
|
|
params.put("xColumn", xColumnName);
|
|
|
|
|
params.put("yColumn", yColumnName);
|
|
|
|
|
EntityWrapper<WenjuandafuEntity> ew = new EntityWrapper<WenjuandafuEntity>();
|
|
|
|
|
String tableName = request.getSession().getAttribute("tableName").toString();
|
|
|
|
|
if(tableName.equals("yonghu")) {
|
|
|
|
|
ew.eq("zhanghao", (String)request.getSession().getAttribute("username"));
|
|
|
|
|
}
|
|
|
|
|
List<Map<String, Object>> result = wenjuandafuService.selectValue(params, ew);
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
for(Map<String, Object> m : result) {
|
|
|
|
|
for(String k : m.keySet()) {
|
|
|
|
|
if(m.get(k) instanceof Date) {
|
|
|
|
|
m.put(k, sdf.format((Date)m.get(k)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return R.ok().put("data", result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 返回封装好的响应结果
|
|
|
|
|
return R.ok().put("data", result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* (按值统计)时间统计类型
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/value/{xColumnName}/{yColumnName}/{timeStatType}")
|
|
|
|
|
public R valueDay(@PathVariable("yColumnName") String yColumnName, @PathVariable("xColumnName") String xColumnName, @PathVariable("timeStatType") String timeStatType, HttpServletRequest request) {
|
|
|
|
|
// 创建参数映射,用于存储请求中的列名和时间统计类型
|
|
|
|
|
Map<String, Object> params = new HashMap<String, Object>();
|
|
|
|
|
params.put("xColumn", xColumnName);
|
|
|
|
|
params.put("yColumn", yColumnName);
|
|
|
|
|
params.put("timeStatType", timeStatType);
|
|
|
|
|
|
|
|
|
|
// 创建实体包装器,用于构建查询条件
|
|
|
|
|
EntityWrapper<WenjuandafuEntity> ew = new EntityWrapper<WenjuandafuEntity>();
|
|
|
|
|
|
|
|
|
|
// 获取当前会话中的表名
|
|
|
|
|
String tableName = request.getSession().getAttribute("tableName").toString();
|
|
|
|
|
|
|
|
|
|
// 如果表名为"yonghu",则添加用户账号作为查询条件
|
|
|
|
|
if (tableName.equals("yonghu")) {
|
|
|
|
|
ew.eq("zhanghao", (String) request.getSession().getAttribute("username"));
|
|
|
|
|
/**
|
|
|
|
|
* (按值统计)时间统计类型
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/value/{xColumnName}/{yColumnName}/{timeStatType}")
|
|
|
|
|
public R valueDay(@PathVariable("yColumnName") String yColumnName, @PathVariable("xColumnName") String xColumnName, @PathVariable("timeStatType") String timeStatType,HttpServletRequest request) {
|
|
|
|
|
Map<String, Object> params = new HashMap<String, Object>();
|
|
|
|
|
params.put("xColumn", xColumnName);
|
|
|
|
|
params.put("yColumn", yColumnName);
|
|
|
|
|
params.put("timeStatType", timeStatType);
|
|
|
|
|
EntityWrapper<WenjuandafuEntity> ew = new EntityWrapper<WenjuandafuEntity>();
|
|
|
|
|
String tableName = request.getSession().getAttribute("tableName").toString();
|
|
|
|
|
if(tableName.equals("yonghu")) {
|
|
|
|
|
ew.eq("zhanghao", (String)request.getSession().getAttribute("username"));
|
|
|
|
|
}
|
|
|
|
|
List<Map<String, Object>> result = wenjuandafuService.selectTimeStatValue(params, ew);
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
for(Map<String, Object> m : result) {
|
|
|
|
|
for(String k : m.keySet()) {
|
|
|
|
|
if(m.get(k) instanceof Date) {
|
|
|
|
|
m.put(k, sdf.format((Date)m.get(k)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return R.ok().put("data", result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 调用服务层方法进行数据查询
|
|
|
|
|
List<Map<String, Object>> result = wenjuandafuService.selectTimeStatValue(params, ew);
|
|
|
|
|
|
|
|
|
|
// 格式化日期对象为字符串
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
for (Map<String, Object> m : result) {
|
|
|
|
|
for (String k : m.keySet()) {
|
|
|
|
|
if (m.get(k) instanceof Date) {
|
|
|
|
|
m.put(k, sdf.format((Date) m.get(k)));
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 分组统计
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/group/{columnName}")
|
|
|
|
|
public R group(@PathVariable("columnName") String columnName,HttpServletRequest request) {
|
|
|
|
|
Map<String, Object> params = new HashMap<String, Object>();
|
|
|
|
|
params.put("column", columnName);
|
|
|
|
|
EntityWrapper<WenjuandafuEntity> ew = new EntityWrapper<WenjuandafuEntity>();
|
|
|
|
|
String tableName = request.getSession().getAttribute("tableName").toString();
|
|
|
|
|
if(tableName.equals("yonghu")) {
|
|
|
|
|
ew.eq("zhanghao", (String)request.getSession().getAttribute("username"));
|
|
|
|
|
}
|
|
|
|
|
List<Map<String, Object>> result = wenjuandafuService.selectGroup(params, ew);
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
for(Map<String, Object> m : result) {
|
|
|
|
|
for(String k : m.keySet()) {
|
|
|
|
|
if(m.get(k) instanceof Date) {
|
|
|
|
|
m.put(k, sdf.format((Date)m.get(k)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return R.ok().put("data", result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 返回封装好的响应结果
|
|
|
|
|
return R.ok().put("data", result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 分组统计
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/group/{columnName}")
|
|
|
|
|
public R group(@PathVariable("columnName") String columnName, HttpServletRequest request) {
|
|
|
|
|
// 创建参数映射,用于存储请求中的列名
|
|
|
|
|
Map<String, Object> params = new HashMap<String, Object>();
|
|
|
|
|
params.put("column", columnName);
|
|
|
|
|
|
|
|
|
|
// 创建实体包装器,用于构建查询条件
|
|
|
|
|
EntityWrapper<WenjuandafuEntity> ew = new EntityWrapper<WenjuandafuEntity>();
|
|
|
|
|
|
|
|
|
|
// 获取当前会话中的表名
|
|
|
|
|
String tableName = request.getSession().getAttribute("tableName").toString();
|
|
|
|
|
|
|
|
|
|
// 如果表名为"yonghu",则添加用户账号作为查询条件
|
|
|
|
|
if (tableName.equals("yonghu")) {
|
|
|
|
|
ew.eq("zhanghao", (String) request.getSession().getAttribute("username"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 调用服务层方法进行数据查询
|
|
|
|
|
List<Map<String, Object>> result = wenjuandafuService.selectGroup(params, ew);
|
|
|
|
|
|
|
|
|
|
// 格式化日期对象为字符串
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
for (Map<String, Object> m : result) {
|
|
|
|
|
for (String k : m.keySet()) {
|
|
|
|
|
if (m.get(k) instanceof Date) {
|
|
|
|
|
m.put(k, sdf.format((Date) m.get(k)));
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 总数量
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/count")
|
|
|
|
|
public R count(@RequestParam Map<String, Object> params,WenjuandafuEntity wenjuandafu, HttpServletRequest request){
|
|
|
|
|
String tableName = request.getSession().getAttribute("tableName").toString();
|
|
|
|
|
if(tableName.equals("yonghu")) {
|
|
|
|
|
wenjuandafu.setZhanghao((String)request.getSession().getAttribute("username"));
|
|
|
|
|
}
|
|
|
|
|
EntityWrapper<WenjuandafuEntity> ew = new EntityWrapper<WenjuandafuEntity>();
|
|
|
|
|
int count = wenjuandafuService.selectCount(MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, wenjuandafu), params), params));
|
|
|
|
|
return R.ok().put("data", count);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 返回封装好的响应结果
|
|
|
|
|
return R.ok().put("data", result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 总数量
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/count")
|
|
|
|
|
public R count(@RequestParam Map<String, Object> params, WenjuandafuEntity wenjuandafu, HttpServletRequest request) {
|
|
|
|
|
// 获取当前会话中的表名
|
|
|
|
|
String tableName = request.getSession().getAttribute("tableName").toString();
|
|
|
|
|
|
|
|
|
|
// 如果表名为"yonghu",则添加用户账号作为查询条件
|
|
|
|
|
if (tableName.equals("yonghu")) {
|
|
|
|
|
wenjuandafu.setZhanghao((String) request.getSession().getAttribute("username"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 创建实体包装器,用于构建查询条件
|
|
|
|
|
EntityWrapper<WenjuandafuEntity> ew = new EntityWrapper<WenjuandafuEntity>();
|
|
|
|
|
|
|
|
|
|
// 调用服务层方法进行数据查询并计算总数
|
|
|
|
|
int count = wenjuandafuService.selectCount(MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, wenjuandafu), params), params));
|
|
|
|
|
|
|
|
|
|
// 返回封装好的响应结果
|
|
|
|
|
return R.ok().put("data", count);
|
|
|
|
|
}
|
|
|
|
|