package com.dian.todolist.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.dian.todolist.common.constant.CronJobConstant;
import com.dian.todolist.common.constant.ItemConstant;
import com.dian.todolist.common.po.BoardPO;
import com.dian.todolist.common.po.CronJobPO;
import com.dian.todolist.common.po.ItemPO;
import com.dian.todolist.mapper.ItemMapper;
import com.dian.todolist.service.BoardService;
import com.dian.todolist.service.CronJobService;
import com.dian.todolist.service.ItemService;
import com.github.yulichang.base.MPJBaseServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.google.common.collect.Lists;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.stream.Collectors;
/**
* <p>
* 服务实现类
* </p>
*
* @author dian
* @since 2022-01-19
*/
@Service
public class ItemServiceImpl extends MPJBaseServiceImpl<ItemMapper, ItemPO> implements ItemService {
@Resource
private ItemMapper itemMapper;
@Resource
private CronJobService cronJobService;
@Resource
private BoardService boardService;
@Override
public Map<String, List<List<String>>> listItemCountByDate(Long userId) {
//获得事项数量
List<Map<String, String>> itemCountList = itemMapper.listItemCountByDate(userId);
//获得已完成事项数量
List<Map<String, String>> itemFinishCountList = itemMapper.listItemFinishByDate(userId);
List<String> count = new ArrayList<>();
List<String> date = new ArrayList<>();
List<String> countFinish = new ArrayList<>();
List<String> dateFinish = new ArrayList<>();
itemCountList.forEach(e -> {
count.add(e.get("date"));
date.add(e.get("count"));
});
itemFinishCountList.forEach(e -> {
countFinish.add(e.get("date"));
dateFinish.add(e.get("count"));
});
List<List<String>> result = Lists.newArrayList(date, count);
List<List<String>> resultFinish = Lists.newArrayList(dateFinish, countFinish);
Map<String, List<List<String>>> map = new HashMap<>();
map.put("item", result);
map.put("itemFinish", resultFinish);
return map;
}
@Override
public List<ItemPO> list1(ItemPO vo) {
ItemPO po = new ItemPO();
BeanUtils.copyProperties(vo, po);
QueryWrapper<ItemPO> itemPOQueryWrapper = new QueryWrapper<>();
itemPOQueryWrapper.setEntity(po);
itemPOQueryWrapper.orderByDesc("create_time");
/*
* 1.不传递status和传递status不等于3的 增加查询条件stauts!=3已删除
* 2.如果传递status=3,则需要查询status=3的
* 先判断是否为null,为null的话执行执行语句块,不需要再判断第二个,防止了空指针
* */
itemPOQueryWrapper.ne(null == vo.getStatus() || ItemConstant.ITEM_STATUS_DELETED != vo.getStatus(), "status", ItemConstant.ITEM_STATUS_DELETED);
itemPOQueryWrapper.between(vo.getBeginDate() != null, "start_date", vo.getBeginDate(), vo.getEndDate());
List<ItemPO> items = super.list(itemPOQueryWrapper);
List<ItemPO> items1 = super.selectJoinList(ItemPO.class,
new MPJLambdaWrapper<ItemPO>()
.selectAll(ItemPO.class)
.selectAs(BoardPO::getName, ItemPO::getBoardName)
.selectAs(BoardPO::getIcon, ItemPO::getBoardIcon)
.selectAs(CronJobPO::getCronStatus, ItemPO::getReminder)
.leftJoin(BoardPO.class, on -> on.eq(BoardPO::getId, ItemPO::getBoardId))
.leftJoin(CronJobPO.class, on -> on
.eq(CronJobPO::getItemId, ItemPO::getId)
.eq(CronJobPO::getCronStatus, CronJobConstant.CRON_STATUS_NORMAL)
.eq(CronJobPO::getIsDeleted, 0))
//这玩意不管用
.setEntity(po)
//默认查询状态不等于3的(已删除)
.ne(null == vo.getStatus() || ItemConstant.ITEM_STATUS_DELETED != vo.getStatus(), ItemPO::getStatus, ItemConstant.ITEM_STATUS_DELETED)
//状态
.eq(null != vo.getStatus(), ItemPO::getStatus, vo.getStatus())
//日期范围
.between(vo.getBeginDate() != null, ItemPO::getStartDate, vo.getBeginDate(), vo.getEndDate())
//所属清单
.eq(null != vo.getBoardId(), ItemPO::getBoardId, vo.getBoardId())
//用户id
.eq(null != vo.getUserId(), ItemPO::getUserId, vo.getUserId())
//从新到旧排序
.orderByDesc(ItemPO::getCreateTime)
);
// //根据boardId统计事项数量
// Map<Long, Long> collect1 = items.stream().collect(Collectors.groupingBy(ItemPO::getBoardId, Collectors.counting()));
// //获得id
// Set<Long> id = collect1.keySet();
// System.out.println("boardid:"+JSONObject.toJSONString(id));
// Iterator iterator = id.iterator();
// Long i = 0L;
// while (iterator.hasNext()) {
// Long j = (Long) iterator.next();
// BoardPO boardPO = boardService.getById(j);
// for (; i < collect1.get(j); i++) {
// items.get(i.intValue()).setBoardName(boardPO.getName());
// items.get(i.intValue()).setBoardIcon(boardPO.getIcon());
//
// }
// }
return items1;
}
@Override
public List<Map<String, Object>> listItemCount(Long userId) {
//根据清单分组查询事项count
QueryWrapper<ItemPO> itemPOQueryWrapper = new QueryWrapper<>();
itemPOQueryWrapper.select("board_id as board", "count(*) as count");
itemPOQueryWrapper.eq("user_id", userId);
itemPOQueryWrapper.ne("status", ItemConstant.ITEM_STATUS_DELETED);
itemPOQueryWrapper.in("status", ItemConstant.ITEM_STATUS_TOP, ItemConstant.ITEM_STATUS_DOING);
itemPOQueryWrapper.groupBy("board_id");
List<Map<String, Object>> maps = super.listMaps(itemPOQueryWrapper);
//状态过滤器
itemPOQueryWrapper.clear();
itemPOQueryWrapper.select("IF( STATUS = 2, '已完成', IF ( status = 3, '垃圾箱', '' ) ) AS board", "count(*) as count");
itemPOQueryWrapper.eq("user_id", userId);
itemPOQueryWrapper.in("status", ItemConstant.ITEM_STATUS_DONE, ItemConstant.ITEM_STATUS_DELETED);
itemPOQueryWrapper.groupBy("status");
List<Map<String, Object>> mapsStatus = super.listMaps(itemPOQueryWrapper);
//日期过滤器
itemPOQueryWrapper.clear();
LocalDate today = LocalDate.now();
LocalDate nextWeek = today.plus(7, ChronoUnit.DAYS);
itemPOQueryWrapper.select("count(*) as count");
itemPOQueryWrapper.eq("user_id", userId);
itemPOQueryWrapper.ne("status", ItemConstant.ITEM_STATUS_DELETED);
itemPOQueryWrapper.in("status", ItemConstant.ITEM_STATUS_TOP, ItemConstant.ITEM_STATUS_DOING);
QueryWrapper<ItemPO> itemPOQueryWrapper2 = itemPOQueryWrapper.clone();
itemPOQueryWrapper.between("start_date", today, today);
itemPOQueryWrapper2.between("start_date", today, nextWeek);
Map<String, Object> dateToday = super.getMap(itemPOQueryWrapper);
Map<String, Objec
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
软件工程毕业设计—基于java+vue的todolist待办事项关联系统前端+后端源码.已获高分通过项目。 软件工程毕业设计—基于java+vue的todolist待办事项关联系统前端+后端源码.已获高分通过项目。软件工程毕业设计—基于java+vue的todolist待办事项关联系统前端+后端源码.已获高分通过项目。软件工程毕业设计—基于java+vue的todolist待办事项关联系统前端+后端源码.已获高分通过项目。软件工程毕业设计—基于java+vue的todolist待办事项关联系统前端+后端源码.已获高分通过项目。软件工程毕业设计—基于java+vue的todolist待办事项关联系统前端+后端源码.已获高分通过项目。软件工程毕业设计—基于java+vue的todolist待办事项关联系统前端+后端源码.已获高分通过项目。软件工程毕业设计—基于java+vue的todolist待办事项关联系统前端+后端源码.已获高分通过项目。
资源推荐
资源详情
资源评论
收起资源包目录
软件工程毕业设计—基于java+vue的todolist待办事项关联系统前端+后端源码.zip (223个子文件)
ItemServiceImpl.class 15KB
ItemController.class 13KB
CronJobServiceImpl.class 11KB
BoardServiceImpl.class 11KB
UserController.class 11KB
QuartzManage.class 9KB
ExcelUtil.class 8KB
LowCodeUtil.class 7KB
UserMessageController.class 7KB
BoardController.class 7KB
SubscribeJob.class 5KB
HabitServiceImpl.class 5KB
ItemPO.class 5KB
CronJobController.class 5KB
CronExpParser.class 5KB
HabitController.class 4KB
GiteeImgBedUtil.class 4KB
MinioUtil.class 4KB
JsonTest.class 3KB
HabitPO.class 3KB
CronJobPO.class 3KB
GiteeController.class 3KB
PageResult.class 3KB
WeekEnum.class 3KB
LoginUserHandlerResolver.class 3KB
UserPO.class 3KB
VerifyCodeUtils.class 3KB
SwaggerConfig.class 3KB
ItemExport.class 3KB
JWTUtils.class 3KB
ListResult.class 3KB
BoardPO.class 2KB
SpringUtils.class 2KB
ImgBedController.class 2KB
ObjectResult.class 2KB
BaseEntity.class 2KB
MinioTest.class 2KB
MailService.class 2KB
UserMessagePO.class 2KB
DictController.class 2KB
DictPO.class 2KB
Json2ObjectUtil.class 2KB
CodeEnum.class 2KB
GlobalExceptionHandle.class 2KB
JwtTest.class 2KB
MailTest.class 2KB
UserMessageServiceImpl.class 2KB
ItemMapper.class 2KB
Result.class 2KB
ResetEntity.class 2KB
BoardExport.class 2KB
CorsConfig.class 2KB
MyMetaObjectHandler.class 1KB
MinioProp.class 1KB
MybatisPlusConfig.class 1KB
ExportItemEntity.class 1KB
HabitService.class 1KB
CronJobService.class 1KB
MinioConfig.class 1KB
ImgException.class 1KB
WebConfig.class 1KB
ItemService.class 1KB
TodolistApplication.class 860B
MessageConstant.class 755B
DictServiceImpl.class 701B
UserServiceImpl.class 701B
CronJobConstant.class 682B
ItemConstant.class 660B
GiteeConstant.class 647B
CronJobMapper.class 628B
BoardService.class 627B
LoginException.class 523B
MailConstant.class 508B
BoardConstant.class 494B
UserMessageService.class 460B
UserMessageMapper.class 411B
LoginUser.class 410B
HabitMapper.class 393B
DictMapper.class 390B
UserMapper.class 390B
BoardMapper.class 377B
UserService.class 320B
DictService.class 320B
.gitignore 214B
EmailVerifyCode.html 1KB
EmailVerifyCode.html 1KB
EmailSubscribe.html 1KB
EmailSubscribe.html 1KB
todolist-all.iml 80B
todolist-1.0-SNAPSHOT.jar 57.18MB
todolist-common-1.0-SNAPSHOT.jar 30KB
todolist-generator-1.0-SNAPSHOT.jar 1KB
ItemServiceImpl.java 9KB
QuartzManage.java 7KB
CronExpParser.java 7KB
ExcelUtil.java 7KB
UserController.java 7KB
CronJobServiceImpl.java 6KB
ItemController.java 6KB
SubscribeJob.java 5KB
共 223 条
- 1
- 2
- 3
程序员张小妍
- 粉丝: 1w+
- 资源: 3474
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页