| | |
| | | package com.example.jz.service.impl; |
| | | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.alibaba.excel.context.AnalysisContext; |
| | | import com.alibaba.excel.event.AnalysisEventListener; |
| | | import com.alibaba.excel.metadata.data.ImageData; |
| | | import com.alibaba.excel.metadata.data.WriteCellData; |
| | | import com.alibaba.excel.util.IoUtils; |
| | |
| | | import com.example.jz.dao.*; |
| | | 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.ReportParamDto; |
| | | import com.example.jz.modle.entity.*; |
| | | import com.example.jz.modle.vo.ExportExcelReportVo; |
| | | import com.example.jz.modle.vo.ReportListVo; |
| | | import com.example.jz.modle.vo.ReportVXVO; |
| | | import com.example.jz.service.MinIOService; |
| | | import com.example.jz.service.ReportService; |
| | | import com.example.jz.service.UserService; |
| | | import lombok.SneakyThrows; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.security.core.context.SecurityContextHolder; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.Comparator; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 报案表(Report)表服务实现类 |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Boolean audit(Report report) { |
| | | // 1. 更新报案表 |
| | | report.setStatus(1); |
| | | report.setIsInGroup(1); |
| | | reportDao.updateById(report); |
| | | // 2. 更新群用户表 |
| | | Group group = groupDao.selectOne(new LambdaQueryWrapper<>(Group.class) |
| | | .eq(Group::getCauseId, report.getCauseId())); |
| | | GroupUser groupUser = new GroupUser().setGroupId(group.getId()).setUserId(report.getId()).setCtime(new Date()).setBanSpeech(0); |
| | | groupUserDao.insert(groupUser); |
| | | if (!groupUserDao.selectUserList(group.getId()).contains(report.getUserId())) { |
| | | GroupUser groupUser = new GroupUser().setGroupId(group.getId()).setUserId(report.getId()).setCtime(new Date()).setBanSpeech(0); |
| | | return groupUserDao.insert(groupUser) == 1 ? true : false; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | |
| | | |
| | | @Override |
| | | public Page<ReportListVo> getPage(Page<ReportListVo> page, ReportParamDto reportParamDto) { |
| | | Page<ReportListVo> aaa = reportDao.getPage(page, reportParamDto); |
| | | aaa.getRecords().stream() |
| | | .forEach(x -> x.setIdcard(x.getIdcard().replaceAll("(?<=[\\d]{3})\\d(?=[\\d]{4})", "*"))); |
| | | return aaa; |
| | | return reportDao.getPage(page, reportParamDto); |
| | | } |
| | | |
| | | @Override |
| | |
| | | .setCtime(new Date()) |
| | | .setStatus(0) |
| | | .setIsInGroup(0) |
| | | .setReportMethod("现场录入") |
| | | .setIsCommission("0").setReportTime(new Date()) |
| | | .setReportMethod("现场报案") |
| | | .setIsCommission("0") |
| | | .setReportTime(new Date()) |
| | | .setCauseId(addReportDto.getCauseId()); |
| | | return reportService.save(report); |
| | | } |
| | | |
| | | @Override |
| | | public List<Report> listGroup(Integer id) { |
| | | return reportDao.selectListGroup(id); |
| | | } |
| | | |
| | | @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 (com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotBlank(data.getReporterName()) && com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotBlank(data.getIdcard())) { |
| | | AddReportDto addReportDto = new AddReportDto(); |
| | | BeanUtils.copyProperties(data, addReportDto); |
| | | addReportDto.setCauseId(causeId); |
| | | addReport(addReportDto); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void doAfterAllAnalysed(AnalysisContext context) { |
| | | |
| | | } |
| | | }) |
| | | .autoCloseStream(true) |
| | | .doReadAll(); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Boolean reject(Integer id, String reason) { |
| | | Report report = reportDao.selectReportByReportId(id); |
| | | // 1. 更新报案表 |
| | | report.setStatus(2); |
| | | report.setIsInGroup(2); |
| | | report.setRemarks(reason); |
| | | reportDao.updateById(report); |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public ReportVXVO getRejectReportById(Integer id) { |
| | | ReportVXVO reportVXVO = new ReportVXVO(); |
| | | Report report = reportDao.selectOne(new LambdaQueryWrapper<Report>().eq(Report::getId, id)); |
| | | User user = userDao.selectOne(new LambdaQueryWrapper<User>().eq(User::getId, report.getUserId())); |
| | | BeanUtils.copyProperties(reportVXVO, report); |
| | | reportVXVO.setLocation(user.getLocation()); |
| | | reportVXVO.setWorkingLocation(user.getWorkingLocation()); |
| | | reportVXVO.setSex(user.getSex()); |
| | | reportVXVO.setRealName(user.getRealName()); |
| | | reportVXVO.setUserIdCard(user.getUserIdcard()); |
| | | return reportVXVO; |
| | | } |
| | | } |