|
|
|
@ -52,331 +52,240 @@ import com.entity.StoreupEntity;
|
|
|
|
|
@RequestMapping("/wenjuandiaocha")
|
|
|
|
|
public class WenjuandiaochaController {
|
|
|
|
|
@Autowired
|
|
|
|
|
private WenjuandiaochaService wenjuandiaochaService;
|
|
|
|
|
|
|
|
|
|
private WenjuandiaochaService wenjuandiaochaService; // 注入问卷调查服务
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private StoreupService storeupService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private StoreupService storeupService; // 注入收藏服务
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 后端列表
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/page")
|
|
|
|
|
public R page(@RequestParam Map<String, Object> params,WenjuandiaochaEntity wenjuandiaocha,
|
|
|
|
|
HttpServletRequest request){
|
|
|
|
|
|
|
|
|
|
EntityWrapper<WenjuandiaochaEntity> ew = new EntityWrapper<WenjuandiaochaEntity>();
|
|
|
|
|
|
|
|
|
|
PageUtils page = wenjuandiaochaService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, wenjuandiaocha), params), params));
|
|
|
|
|
request.setAttribute("data", page);
|
|
|
|
|
return R.ok().put("data", page);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 前端列表
|
|
|
|
|
*/
|
|
|
|
|
@IgnoreAuth
|
|
|
|
|
@RequestMapping("/list")
|
|
|
|
|
public R list(@RequestParam Map<String, Object> params,WenjuandiaochaEntity wenjuandiaocha,
|
|
|
|
|
HttpServletRequest request){
|
|
|
|
|
EntityWrapper<WenjuandiaochaEntity> ew = new EntityWrapper<WenjuandiaochaEntity>();
|
|
|
|
|
|
|
|
|
|
PageUtils page = wenjuandiaochaService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, wenjuandiaocha), params), params));
|
|
|
|
|
request.setAttribute("data", page);
|
|
|
|
|
return R.ok().put("data", page);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 列表
|
|
|
|
|
* 提醒接口
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/lists")
|
|
|
|
|
public R list( WenjuandiaochaEntity wenjuandiaocha){
|
|
|
|
|
EntityWrapper<WenjuandiaochaEntity> ew = new EntityWrapper<WenjuandiaochaEntity>();
|
|
|
|
|
ew.allEq(MPUtil.allEQMapPre( wenjuandiaocha, "wenjuandiaocha"));
|
|
|
|
|
return R.ok().put("data", wenjuandiaochaService.selectListView(ew));
|
|
|
|
|
}
|
|
|
|
|
@RequestMapping("/remind/{columnName}/{type}")
|
|
|
|
|
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
|
|
|
|
|
@PathVariable("type") String type, @RequestParam Map<String, Object> map) {
|
|
|
|
|
// 将列名和类型添加到 map 中
|
|
|
|
|
map.put("column", columnName);
|
|
|
|
|
map.put("type", type);
|
|
|
|
|
|
|
|
|
|
// 如果类型为 "2",处理日期范围
|
|
|
|
|
if (type.equals("2")) {
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // 定义日期格式
|
|
|
|
|
Calendar c = Calendar.getInstance(); // 获取当前日期时间
|
|
|
|
|
Date remindStartDate = null;
|
|
|
|
|
Date remindEndDate = null;
|
|
|
|
|
|
|
|
|
|
// 处理 remindstart 参数
|
|
|
|
|
if (map.get("remindstart") != null) {
|
|
|
|
|
Integer remindStart = Integer.parseInt(map.get("remindstart").toString()); // 将 remindstart 转换为整数
|
|
|
|
|
c.setTime(new Date()); // 设置当前时间
|
|
|
|
|
c.add(Calendar.DAY_OF_MONTH, remindStart); // 添加 remindStart 天
|
|
|
|
|
remindStartDate = c.getTime(); // 获取新的开始日期
|
|
|
|
|
map.put("remindstart", sdf.format(remindStartDate)); // 格式化并添加到 map 中
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 处理 remindend 参数
|
|
|
|
|
if (map.get("remindend") != null) {
|
|
|
|
|
Integer remindEnd = Integer.parseInt(map.get("remindend").toString()); // 将 remindend 转换为整数
|
|
|
|
|
c.setTime(new Date()); // 设置当前时间
|
|
|
|
|
c.add(Calendar.DAY_OF_MONTH, remindEnd); // 添加 remindEnd 天
|
|
|
|
|
remindEndDate = c.getTime(); // 获取新的结束日期
|
|
|
|
|
map.put("remindend", sdf.format(remindEndDate)); // 格式化并添加到 map 中
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 创建 EntityWrapper 对象,用于构建查询条件
|
|
|
|
|
Wrapper<WenjuandiaochaEntity> wrapper = new EntityWrapper<WenjuandiaochaEntity>();
|
|
|
|
|
if (map.get("remindstart") != null) {
|
|
|
|
|
wrapper.ge(columnName, map.get("remindstart")); // 大于等于 remindstart
|
|
|
|
|
}
|
|
|
|
|
if (map.get("remindend") != null) {
|
|
|
|
|
wrapper.le(columnName, map.get("remindend")); // 小于等于 remindend
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/query")
|
|
|
|
|
public R query(WenjuandiaochaEntity wenjuandiaocha){
|
|
|
|
|
EntityWrapper< WenjuandiaochaEntity> ew = new EntityWrapper< WenjuandiaochaEntity>();
|
|
|
|
|
ew.allEq(MPUtil.allEQMapPre( wenjuandiaocha, "wenjuandiaocha"));
|
|
|
|
|
WenjuandiaochaView wenjuandiaochaView = wenjuandiaochaService.selectView(ew);
|
|
|
|
|
return R.ok("查询问卷调查成功").put("data", wenjuandiaochaView);
|
|
|
|
|
// 查询符合条件的记录数
|
|
|
|
|
int count = wenjuandiaochaService.selectCount(wrapper);
|
|
|
|
|
return R.ok().put("count", count); // 返回记录数
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 后端详情
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/info/{id}")
|
|
|
|
|
public R info(@PathVariable("id") Long id){
|
|
|
|
|
WenjuandiaochaEntity wenjuandiaocha = wenjuandiaochaService.selectById(id);
|
|
|
|
|
wenjuandiaocha.setClicktime(new Date());
|
|
|
|
|
wenjuandiaochaService.updateById(wenjuandiaocha);
|
|
|
|
|
return R.ok().put("data", wenjuandiaocha);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 前端详情
|
|
|
|
|
*/
|
|
|
|
|
@IgnoreAuth
|
|
|
|
|
@RequestMapping("/detail/{id}")
|
|
|
|
|
public R detail(@PathVariable("id") Long id){
|
|
|
|
|
WenjuandiaochaEntity wenjuandiaocha = wenjuandiaochaService.selectById(id);
|
|
|
|
|
wenjuandiaocha.setClicktime(new Date());
|
|
|
|
|
wenjuandiaochaService.updateById(wenjuandiaocha);
|
|
|
|
|
return R.ok().put("data", wenjuandiaocha);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 后端保存
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/save")
|
|
|
|
|
public R save(@RequestBody WenjuandiaochaEntity wenjuandiaocha, HttpServletRequest request){
|
|
|
|
|
wenjuandiaocha.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
|
|
|
|
|
//ValidatorUtils.validateEntity(wenjuandiaocha);
|
|
|
|
|
|
|
|
|
|
wenjuandiaochaService.insert(wenjuandiaocha);
|
|
|
|
|
return R.ok();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 前端保存
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/add")
|
|
|
|
|
public R add(@RequestBody WenjuandiaochaEntity wenjuandiaocha, HttpServletRequest request){
|
|
|
|
|
wenjuandiaocha.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
|
|
|
|
|
//ValidatorUtils.validateEntity(wenjuandiaocha);
|
|
|
|
|
|
|
|
|
|
wenjuandiaochaService.insert(wenjuandiaocha);
|
|
|
|
|
return R.ok();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 修改
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/update")
|
|
|
|
|
@Transactional
|
|
|
|
|
public R update(@RequestBody WenjuandiaochaEntity wenjuandiaocha, HttpServletRequest request){
|
|
|
|
|
//ValidatorUtils.validateEntity(wenjuandiaocha);
|
|
|
|
|
wenjuandiaochaService.updateById(wenjuandiaocha);//全部更新
|
|
|
|
|
return R.ok();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 删除
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/delete")
|
|
|
|
|
public R delete(@RequestBody Long[] ids){
|
|
|
|
|
wenjuandiaochaService.deleteBatchIds(Arrays.asList(ids));
|
|
|
|
|
return R.ok();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 提醒接口
|
|
|
|
|
*/
|
|
|
|
|
@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<WenjuandiaochaEntity> wrapper = new EntityWrapper<WenjuandiaochaEntity>();
|
|
|
|
|
if(map.get("remindstart")!=null) {
|
|
|
|
|
wrapper.ge(columnName, map.get("remindstart"));
|
|
|
|
|
}
|
|
|
|
|
if(map.get("remindend")!=null) {
|
|
|
|
|
wrapper.le(columnName, map.get("remindend"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int count = wenjuandiaochaService.selectCount(wrapper);
|
|
|
|
|
return R.ok().put("count", count);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 前端智能排序
|
|
|
|
|
*/
|
|
|
|
|
@IgnoreAuth
|
|
|
|
|
@IgnoreAuth // 忽略认证
|
|
|
|
|
@RequestMapping("/autoSort")
|
|
|
|
|
public R autoSort(@RequestParam Map<String, Object> params,WenjuandiaochaEntity wenjuandiaocha, HttpServletRequest request,String pre){
|
|
|
|
|
public R autoSort(@RequestParam Map<String, Object> params, WenjuandiaochaEntity wenjuandiaocha, HttpServletRequest request, String pre) {
|
|
|
|
|
// 创建 EntityWrapper 对象,用于构建查询条件
|
|
|
|
|
EntityWrapper<WenjuandiaochaEntity> ew = new EntityWrapper<WenjuandiaochaEntity>();
|
|
|
|
|
Map<String, Object> newMap = new HashMap<String, Object>();
|
|
|
|
|
Map<String, Object> param = new HashMap<String, Object>();
|
|
|
|
|
Iterator<Map.Entry<String, Object>> it = param.entrySet().iterator();
|
|
|
|
|
while (it.hasNext()) {
|
|
|
|
|
Map.Entry<String, Object> entry = it.next();
|
|
|
|
|
String key = entry.getKey();
|
|
|
|
|
String newKey = entry.getKey();
|
|
|
|
|
if (pre.endsWith(".")) {
|
|
|
|
|
newMap.put(pre + newKey, entry.getValue());
|
|
|
|
|
} else if (StringUtils.isEmpty(pre)) {
|
|
|
|
|
newMap.put(newKey, entry.getValue());
|
|
|
|
|
} else {
|
|
|
|
|
newMap.put(pre + "." + newKey, entry.getValue());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
params.put("sort", "clicktime");
|
|
|
|
|
Iterator<Map.Entry<String, Object>> it = param.entrySet().iterator();
|
|
|
|
|
while (it.hasNext()) {
|
|
|
|
|
Map.Entry<String, Object> entry = it.next();
|
|
|
|
|
String key = entry.getKey();
|
|
|
|
|
String newKey = entry.getKey();
|
|
|
|
|
|
|
|
|
|
// 处理 pre 参数
|
|
|
|
|
if (pre.endsWith(".")) {
|
|
|
|
|
newMap.put(pre + newKey, entry.getValue());
|
|
|
|
|
} else if (StringUtils.isEmpty(pre)) {
|
|
|
|
|
newMap.put(newKey, entry.getValue());
|
|
|
|
|
} else {
|
|
|
|
|
newMap.put(pre + "." + newKey, entry.getValue());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 设置排序条件
|
|
|
|
|
params.put("sort", "clicktime");
|
|
|
|
|
params.put("order", "desc");
|
|
|
|
|
PageUtils page = wenjuandiaochaService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, wenjuandiaocha), params), params));
|
|
|
|
|
return R.ok().put("data", page);
|
|
|
|
|
|
|
|
|
|
// 查询分页数据
|
|
|
|
|
PageUtils page = wenjuandiaochaService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, wenjuandiaocha), params), params));
|
|
|
|
|
return R.ok().put("data", page); // 返回分页数据
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 协同算法(按收藏推荐)
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/autoSort2")
|
|
|
|
|
public R autoSort2(@RequestParam Map<String, Object> params,WenjuandiaochaEntity wenjuandiaocha, HttpServletRequest request){
|
|
|
|
|
public R autoSort2(@RequestParam Map<String, Object> params, WenjuandiaochaEntity wenjuandiaocha, HttpServletRequest request) {
|
|
|
|
|
// 获取用户 ID
|
|
|
|
|
String userId = request.getSession().getAttribute("userId").toString();
|
|
|
|
|
String inteltypeColumn = "leixing";
|
|
|
|
|
String inteltypeColumn = "leixing"; // 定义智能类型列名
|
|
|
|
|
List<StoreupEntity> storeups = storeupService.selectList(new EntityWrapper<StoreupEntity>().eq("type", 1).eq("userid", userId).eq("tablename", "wenjuandiaocha").orderBy("addtime", false));
|
|
|
|
|
List<String> inteltypes = new ArrayList<String>();
|
|
|
|
|
Integer limit = params.get("limit")==null?10:Integer.parseInt(params.get("limit").toString());
|
|
|
|
|
Integer limit = params.get("limit") == null ? 10 : Integer.parseInt(params.get("limit").toString()); // 设置限制数量,默认为 10
|
|
|
|
|
List<WenjuandiaochaEntity> wenjuandiaochaList = new ArrayList<WenjuandiaochaEntity>();
|
|
|
|
|
//去重
|
|
|
|
|
if(storeups!=null && storeups.size()>0) {
|
|
|
|
|
for(StoreupEntity s : storeups) {
|
|
|
|
|
|
|
|
|
|
// 去重
|
|
|
|
|
if (storeups != null && storeups.size() > 0) {
|
|
|
|
|
for (StoreupEntity s : storeups) {
|
|
|
|
|
wenjuandiaochaList.addAll(wenjuandiaochaService.selectList(new EntityWrapper<WenjuandiaochaEntity>().eq(inteltypeColumn, s.getInteltype())));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 创建 EntityWrapper 对象,用于构建查询条件
|
|
|
|
|
EntityWrapper<WenjuandiaochaEntity> ew = new EntityWrapper<WenjuandiaochaEntity>();
|
|
|
|
|
params.put("sort", "id");
|
|
|
|
|
params.put("order", "desc");
|
|
|
|
|
|
|
|
|
|
// 查询分页数据
|
|
|
|
|
PageUtils page = wenjuandiaochaService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, wenjuandiaocha), params), params));
|
|
|
|
|
List<WenjuandiaochaEntity> pageList = (List<WenjuandiaochaEntity>)page.getList();
|
|
|
|
|
if(wenjuandiaochaList.size()<limit) {
|
|
|
|
|
int toAddNum = (limit-wenjuandiaochaList.size())<=pageList.size()?(limit-wenjuandiaochaList.size()):pageList.size();
|
|
|
|
|
for(WenjuandiaochaEntity o1 : pageList) {
|
|
|
|
|
List<WenjuandiaochaEntity> pageList = (List<WenjuandiaochaEntity>) page.getList();
|
|
|
|
|
|
|
|
|
|
// 如果结果数量小于限制数量,则从分页数据中添加
|
|
|
|
|
if (wenjuandiaochaList.size() < limit) {
|
|
|
|
|
int toAddNum = (limit - wenjuandiaochaList.size()) <= pageList.size() ? (limit - wenjuandiaochaList.size()) : pageList.size();
|
|
|
|
|
for (WenjuandiaochaEntity o1 : pageList) {
|
|
|
|
|
boolean addFlag = true;
|
|
|
|
|
for(WenjuandiaochaEntity o2 : wenjuandiaochaList) {
|
|
|
|
|
if(o1.getId().intValue()==o2.getId().intValue()) {
|
|
|
|
|
for (WenjuandiaochaEntity o2 : wenjuandiaochaList) {
|
|
|
|
|
if (o1.getId().intValue() == o2.getId().intValue()) {
|
|
|
|
|
addFlag = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(addFlag) {
|
|
|
|
|
if (addFlag) {
|
|
|
|
|
wenjuandiaochaList.add(o1);
|
|
|
|
|
if(--toAddNum==0) break;
|
|
|
|
|
if (--toAddNum == 0) break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else if(wenjuandiaochaList.size()>limit) {
|
|
|
|
|
wenjuandiaochaList = wenjuandiaochaList.subList(0, limit);
|
|
|
|
|
} else if (wenjuandiaochaList.size() > limit) {
|
|
|
|
|
wenjuandiaochaList = wenjuandiaochaList.subList(0, limit); // 如果结果数量大于限制数量,则截取前 limit 个
|
|
|
|
|
}
|
|
|
|
|
page.setList(wenjuandiaochaList);
|
|
|
|
|
return R.ok().put("data", page);
|
|
|
|
|
|
|
|
|
|
page.setList(wenjuandiaochaList); // 设置新的列表
|
|
|
|
|
return R.ok().put("data", page); // 返回分页数据
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* (按值统计)
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/value/{xColumnName}/{yColumnName}")
|
|
|
|
|
public R value(@PathVariable("yColumnName") String yColumnName, @PathVariable("xColumnName") String xColumnName,HttpServletRequest request) {
|
|
|
|
|
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 对象,用于构建查询条件
|
|
|
|
|
EntityWrapper<WenjuandiaochaEntity> ew = new EntityWrapper<WenjuandiaochaEntity>();
|
|
|
|
|
|
|
|
|
|
// 查询统计结果
|
|
|
|
|
List<Map<String, Object>> result = wenjuandiaochaService.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)));
|
|
|
|
|
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) {
|
|
|
|
|
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 对象,用于构建查询条件
|
|
|
|
|
EntityWrapper<WenjuandiaochaEntity> ew = new EntityWrapper<WenjuandiaochaEntity>();
|
|
|
|
|
|
|
|
|
|
// 查询时间统计结果
|
|
|
|
|
List<Map<String, Object>> result = wenjuandiaochaService.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)));
|
|
|
|
|
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) {
|
|
|
|
|
public R group(@PathVariable("columnName") String columnName, HttpServletRequest request) {
|
|
|
|
|
Map<String, Object> params = new HashMap<String, Object>();
|
|
|
|
|
params.put("column", columnName);
|
|
|
|
|
|
|
|
|
|
// 创建 EntityWrapper 对象,用于构建查询条件
|
|
|
|
|
EntityWrapper<WenjuandiaochaEntity> ew = new EntityWrapper<WenjuandiaochaEntity>();
|
|
|
|
|
|
|
|
|
|
// 查询分组统计结果
|
|
|
|
|
List<Map<String, Object>> result = wenjuandiaochaService.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)));
|
|
|
|
|
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("/count")
|
|
|
|
|
public R count(@RequestParam Map<String, Object> params,WenjuandiaochaEntity wenjuandiaocha, HttpServletRequest request){
|
|
|
|
|
public R count(@RequestParam Map<String, Object> params, WenjuandiaochaEntity wenjuandiaocha, HttpServletRequest request) {
|
|
|
|
|
// 创建 EntityWrapper 对象,用于构建查询条件
|
|
|
|
|
EntityWrapper<WenjuandiaochaEntity> ew = new EntityWrapper<WenjuandiaochaEntity>();
|
|
|
|
|
|
|
|
|
|
// 查询符合条件的记录数
|
|
|
|
|
int count = wenjuandiaochaService.selectCount(MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, wenjuandiaocha), params), params));
|
|
|
|
|
return R.ok().put("data", count);
|
|
|
|
|
return R.ok().put("data", count); // 返回记录数
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|