| | |
| | | import com.example.jz.exception.BusinessException; |
| | | import com.example.jz.modle.PageParam; |
| | | import com.example.jz.modle.dto.AddReportDto; |
| | | import com.example.jz.modle.dto.AddReportLoadDto; |
| | | import com.example.jz.modle.dto.CauseDto; |
| | | import com.example.jz.modle.dto.CauseLoadDto; |
| | | import com.example.jz.modle.entity.*; |
| | |
| | | import com.example.jz.modle.vo.CauseVo; |
| | | import com.example.jz.modle.vo.UserVo; |
| | | import com.example.jz.service.CauseService; |
| | | import com.example.jz.service.ReportService; |
| | | import com.example.jz.service.UserService; |
| | | import lombok.SneakyThrows; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.security.core.context.SecurityContextHolder; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | |
| | | GroupDao groupDao; |
| | | @Resource |
| | | GroupUserDao groupUserDao; |
| | | @Resource |
| | | UserService userService; |
| | | @Resource |
| | | ReportService reportService; |
| | | |
| | | @Resource |
| | | AnnouncementDao announcementDao; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public PageParam<CauseVo> getCauserListByCondition(String cause, Integer status, Integer size, Integer current,Integer id) { |
| | | QueryWrapper<Cause> causeQueryWrapper = new QueryWrapper<>(); |
| | | if (StringUtils.isNotBlank(cause)) { |
| | | causeQueryWrapper.and(a -> a.like(StringUtils.isNotBlank(cause), "number", cause) |
| | | .or(StringUtils.isNotBlank(cause)) |
| | | .like(StringUtils.isNotBlank(cause), "name", cause)); |
| | | } |
| | | if (status != null) { |
| | | causeQueryWrapper.eq("status", status); |
| | | } |
| | | causeQueryWrapper.eq("user_id",id); |
| | | causeQueryWrapper.orderByDesc("ctime"); |
| | | PageParam<Cause> causePageParam = new PageParam<>(); |
| | | if (size != null) { |
| | | causePageParam.setSize(size); |
| | | } |
| | | if (current != null) { |
| | | causePageParam.setCurrent(current); |
| | | } |
| | | PageParam<Cause> causePage = causeDao.selectPage(causePageParam, causeQueryWrapper); |
| | | List<CauseVo> causeVos = causePage.getRecords().stream().map( |
| | | a -> { |
| | | CauseVo causeVo = new CauseVo(); |
| | | BeanUtils.copyProperties(a, causeVo); |
| | | causeVo.setUserName(userDao.selectOne(new QueryWrapper<User>().eq("id", a.getUserId())).getRealName()); |
| | | causeVo.setReportNumber(reportDao.selectCount(new QueryWrapper<Report>().eq("cause_id", a.getId()))); |
| | | causeVo.setGroupId(groupDao.selectOne(new QueryWrapper<Group>().eq("cause_id", a.getId())).getId()); |
| | | return causeVo; |
| | | }).collect(Collectors.toList()); |
| | | PageParam<CauseVo> causeVoPageParam = new PageParam<>(); |
| | | BeanUtils.copyProperties(causePage, causeVoPageParam); |
| | | causeVoPageParam.setRecords(causeVos); |
| | | return causeVoPageParam; |
| | | } |
| | | |
| | | @Override |
| | | public List<UserVo> getManagerList() { |
| | | return userDao.selectList(new QueryWrapper<User>().eq("role", 1)).stream().map(a -> { |
| | | UserVo userVo = new UserVo(); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<CauseReportVo> getReporterList(Integer causeId) { |
| | | return reportDao.selectList(new QueryWrapper<Report>().eq("cause_id", causeId)).stream() |
| | | .map( |
| | | a -> { |
| | | CauseReportVo causeReportVo = new CauseReportVo(); |
| | | User user = userDao.selectOne(new QueryWrapper<User>().eq("id", a.getUserId())); |
| | | BeanUtils.copyProperties(a, causeReportVo); |
| | | causeReportVo.setUserIdcard(user.getUserIdcard()); |
| | | causeReportVo.setUserMobile(user.getUserMobile()); |
| | | causeReportVo.setUserIdcard(causeReportVo.getUserIdcard().replaceAll("(?<=[\\d]{3})\\d(?=[\\d]{4})", "*")); |
| | | causeReportVo.setUserName(user.getRealName()); |
| | | return causeReportVo; |
| | | } |
| | | ).collect(Collectors.toList()); |
| | | public PageParam<CauseReportVo> getReporterList(Integer causeId) { |
| | | PageParam<Report> PageParam = new PageParam<>(); |
| | | PageParam<Report> reportPageParam = reportDao.selectPage(PageParam, new QueryWrapper<Report>().eq("cause_id", causeId).orderByDesc("ctime")); |
| | | PageParam<CauseReportVo> causeReportVoPageParam = new PageParam<>(); |
| | | BeanUtils.copyProperties(reportPageParam, causeReportVoPageParam); |
| | | if (!reportPageParam.getRecords().isEmpty()){ |
| | | List<CauseReportVo> causeReportVos = reportPageParam.getRecords().stream() |
| | | .map( |
| | | a -> { |
| | | CauseReportVo causeReportVo = new CauseReportVo(); |
| | | User user = userDao.selectOne(new QueryWrapper<User>().eq("id", a.getUserId())); |
| | | BeanUtils.copyProperties(a, causeReportVo); |
| | | causeReportVo.setMobile(user.getUserMobile()); |
| | | causeReportVo.setIdcard(user.getUserIdcard().replaceAll("(?<=[\\d]{3})\\d(?=[\\d]{4})", "*")); |
| | | causeReportVo.setReporterName(user.getRealName()); |
| | | if (causeReportVo.getIsInGroup()==1) { |
| | | causeReportVo.setGroupId(groupDao.selectOne(new QueryWrapper<Group>().eq("cause_id",causeId)).getId()); |
| | | } |
| | | return causeReportVo; |
| | | } |
| | | ).collect(Collectors.toList()); |
| | | causeReportVoPageParam.setRecords(causeReportVos); |
| | | } |
| | | return causeReportVoPageParam; |
| | | } |
| | | |
| | | @Override |
| | |
| | | @Override |
| | | public void deleteCause(Integer id) { |
| | | causeDao.deleteById(id); |
| | | groupDao.delete(new QueryWrapper<Group>().eq("cause_id", id)); |
| | | } |
| | | |
| | | @Override |
| | |
| | | EasyExcel.read(multipartFile.getInputStream(), CauseLoadDto.class, new AnalysisEventListener<CauseLoadDto>() { |
| | | @Override |
| | | public void invoke(CauseLoadDto data, AnalysisContext context) { |
| | | if (StringUtils.isNotBlank(data.getName())&&StringUtils.isNotBlank(data.getUserName())){ |
| | | if (StringUtils.isNotBlank(data.getName()) && StringUtils.isNotBlank(data.getUserName())) { |
| | | causeLoadDtos.add(data); |
| | | } |
| | | } |
| | |
| | | // 如果用户不存在 则添加用户 |
| | | user = new User().setUserIdcard(addReportDto.getIdcard()).setUserMobile(addReportDto.getMobile()).setRealName(addReportDto.getReporterName()) |
| | | .setModifyTime(new Date()).setUserRegtime(new Date()).setPic(addReportDto.getPic()); |
| | | userDao.insert(user); |
| | | userService.save(user); |
| | | } |
| | | Group group = groupDao.selectOne(new QueryWrapper<Group>().eq("cause_id", addReportDto.getCauseId())); |
| | | // 添加人员进群组 |
| | | groupUserDao.insert(new GroupUser().setGroupId(addReportDto.getGroupId()).setUserId(user.getId()).setCtime(new Date()).setBanSpeech(0)); |
| | | // groupUserDao.insert(new GroupUser().setGroupId(group.getId()).setUserId(user.getId()).setCtime(new Date()).setBanSpeech(0)); |
| | | // 添加报案信息 |
| | | Report report = new Report(); |
| | | BeanUtils.copyProperties(addReportDto, report); |
| | | report |
| | | .setIsInGroup(1) |
| | | .setCreator(userDao.selectOne(new QueryWrapper<User>().eq("login_username", SecurityContextHolder.getContext().getAuthentication().getPrincipal())).getId()) |
| | | .setUserId(user.getId()) |
| | | .setCtime(new Date()) |
| | | .setStatus(0) |
| | | .setReportMethod("现场录入") |
| | | .setReportMethod("后台录入") |
| | | .setIsCommission("0").setReportTime(new Date()) |
| | | .setCauseId(groupDao.selectOne(new QueryWrapper<Group>().eq("id", addReportDto.getGroupId())).getCauseId()); |
| | | return reportDao.insert(report) > 0; |
| | | .setCauseId(addReportDto.getCauseId()); |
| | | reportService.save(report); |
| | | return groupUserDao.insert(new GroupUser().setGroupId(group.getId()).setUserId(report.getId()).setCtime(new Date()).setBanSpeech(0))> 0; |
| | | } |
| | | |
| | | @Override |
| | |
| | | }); |
| | | return maps; |
| | | } |
| | | |
| | | @Override |
| | | @SneakyThrows |
| | | public void loadFileReport(MultipartFile multipartFile,Integer causeId) { |
| | | EasyExcel.read(multipartFile.getInputStream(), AddReportLoadDto.class, new AnalysisEventListener<AddReportLoadDto>() { |
| | | @Override |
| | | public void invoke(AddReportLoadDto data, AnalysisContext context) { |
| | | if (StringUtils.isNotBlank(data.getReporterName())&&StringUtils.isNotBlank(data.getIdcard())){ |
| | | AddReportDto addReportDto = new AddReportDto(); |
| | | BeanUtils.copyProperties(data,addReportDto); |
| | | addReportDto.setCauseId(causeId); |
| | | addReportPeople(addReportDto); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void doAfterAllAnalysed(AnalysisContext context) { |
| | | |
| | | } |
| | | }) |
| | | .autoCloseStream(true) |
| | | .doReadAll(); |
| | | } |
| | | } |