package com.example.jz.service.impl;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.example.jz.dao.*;
|
import com.example.jz.modle.entity.*;
|
import com.example.jz.modle.vo.MessageVo;
|
import com.example.jz.modle.vo.ReportVo;
|
import com.example.jz.service.WorkbenchService;
|
import org.springframework.beans.BeanUtils;
|
import org.springframework.stereotype.Service;
|
|
import javax.annotation.Resource;
|
import java.util.ArrayList;
|
import java.util.List;
|
|
@Service
|
public class WorkbenchServiceImpl implements WorkbenchService {
|
@Resource
|
ReportDao reportDao;
|
|
@Resource
|
CauseDao causeDao;
|
|
@Resource
|
UserDao userDao;
|
|
@Resource
|
GroupDao groupDao;
|
|
@Resource
|
GroupUserDao groupUserDao;
|
|
|
@Resource
|
MessageDao messageDao;
|
|
@Override
|
public Integer getCheckPending() {
|
return reportDao.selectCount(new QueryWrapper<Report>().eq("status", 0).last("and TO_DAYS(ctime)=TO_DAYS(NOW())"));
|
}
|
|
@Override
|
public Integer getCheckPended() {
|
return reportDao.selectCount(new QueryWrapper<Report>().eq("status", 1).last("and TO_DAYS(ctime)=TO_DAYS(NOW())"));
|
}
|
|
@Override
|
public Integer getIntoGroupNumbers() {
|
return groupUserDao.selectCount(new QueryWrapper<GroupUser>().apply("TO_DAYS(ctime)=TO_DAYS(NOW())"));
|
}
|
|
@Override
|
public Integer getNewCase() {
|
return causeDao.selectCount(new QueryWrapper<Cause>().apply("TO_DAYS(ctime)=TO_DAYS(NOW())"));
|
}
|
|
@Override
|
public Integer getAllCase() {
|
return causeDao.selectCount(new QueryWrapper<>());
|
}
|
|
@Override
|
public Integer getAllManager() {
|
return userDao.selectCount(new QueryWrapper<User>().eq("role", 1));
|
}
|
|
@Override
|
public List<ReportVo> getAllCheckPendingList() {
|
//查询待审核人
|
List<Report> reports = reportDao.selectList(new QueryWrapper<Report>().eq("status", 0).orderByDesc("ctime").last("limit 5"));
|
ArrayList<ReportVo> reportVos = new ArrayList<>();
|
if(!reports.isEmpty()){
|
reports.forEach(a -> {
|
User user = userDao.selectOne(new QueryWrapper<User>().eq("id", a.getUserId()));
|
ReportVo reportVo = new ReportVo();
|
if (user!=null){
|
reportVo.setReporterName(user.getRealName());
|
String regex = "(?<=[\\d]{3})\\d(?=[\\d]{4})";
|
reportVo.setIdcard(user.getUserIdcard().replaceAll(regex, "*"));
|
reportVo.setMobile(user.getUserMobile());
|
}
|
// reportVo.setId(a.getId());
|
reportVos.add(reportVo);
|
});
|
}
|
return reportVos;
|
}
|
|
@Override
|
public List<MessageVo> getGroupMessage() {
|
ArrayList<MessageVo> messageVos = new ArrayList<>();
|
if (!messageVos.isEmpty()){
|
messageDao.selectList(new QueryWrapper<Message>().orderByDesc("ctime")).stream()
|
.filter(item->item.getUserId()!=null).limit(5).forEach(a -> {
|
MessageVo messageVo = new MessageVo();
|
messageVo.setGroupName(groupDao.selectOne(new QueryWrapper<Group>().eq("id", a.getGroupId())).getGroupName());
|
BeanUtils.copyProperties(a, messageVo);
|
messageVo.setUserName(a.getReportName());
|
messageVos.add(messageVo);
|
});
|
}
|
return messageVos;
|
}
|
}
|