| | |
| | | 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.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.example.jz.dao.*; |
| | | import com.example.jz.enums.CauseEnums; |
| | | 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.CauseDto; |
| | | import com.example.jz.modle.dto.CauseLoadDto; |
| | | import com.example.jz.modle.entity.*; |
| | | import com.example.jz.modle.vo.AnnouncementVo; |
| | | import com.example.jz.modle.vo.CauseReportVo; |
| | | import com.example.jz.modle.vo.CauseVo; |
| | | import com.example.jz.modle.vo.UserVo; |
| | | import com.example.jz.service.CauseService; |
| | | import lombok.SneakyThrows; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * ������(Cause)�����ʵ���� |
| | | * 案件表(Cause)表服务实现类 |
| | | * |
| | | * @author makejava |
| | | * @since 2022-07-13 11:52:58 |
| | |
| | | BeanUtils.copyProperties(causeDto, cause); |
| | | cause.setCtime(new Date()); |
| | | causeService.save(cause); |
| | | //����Ⱥ�� |
| | | //创建群组 |
| | | Group group = new Group(); |
| | | group.setCtime(new Date()); |
| | | group.setGroupName(causeDto.getName()); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<AnnouncementVo> getGroupAnnouncement(Integer groupId) { |
| | | return announcementDao.selectList(new QueryWrapper<Announcement>().eq("group_id", groupId)).stream() |
| | | .map( |
| | | a -> { |
| | | AnnouncementVo announcementVo = new AnnouncementVo(); |
| | | BeanUtils.copyProperties(a, announcementVo); |
| | | return announcementVo; |
| | | } |
| | | ).collect(Collectors.toList()); |
| | | public List<Announcement> getGroupAnnouncement(Integer groupId) { |
| | | return announcementDao.selectList(new QueryWrapper<Announcement>().eq("group_id", groupId)); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | |
| | | @Override |
| | | @SneakyThrows |
| | | @Transactional(rollbackFor = BusinessException.class) |
| | | public void loadFile(MultipartFile multipartFile) { |
| | | ArrayList<CauseLoadDto> causeLoadDtos = new ArrayList<>(); |
| | | EasyExcel.read(multipartFile.getInputStream(),CauseLoadDto.class, new AnalysisEventListener<CauseLoadDto>() { |
| | | @Override |
| | | public void invoke(CauseLoadDto data, AnalysisContext context) { |
| | | causeLoadDtos.add(data); |
| | | } |
| | | |
| | | @Override |
| | | public void doAfterAllAnalysed(AnalysisContext analysisContext) { |
| | | |
| | | } |
| | | }) |
| | | .autoCloseStream(true) |
| | | .doReadAll(); |
| | | causeLoadDtos.forEach( |
| | | a -> { |
| | | Cause cause = new Cause(); |
| | | BeanUtils.copyProperties(a, cause); |
| | | if (StringUtils.isBlank(a.getStatus())){ |
| | | throw new BusinessException("状态不能为空"); |
| | | } |
| | | if (a.getStatus().equals(CauseEnums.UNCHECKED.getMsg())) { |
| | | cause.setStatus(CauseEnums.UNCHECKED.value()); |
| | | } |
| | | if (a.getStatus().equals(CauseEnums.NOTTOPUTONRECORD.getMsg())) { |
| | | cause.setStatus(CauseEnums.NOTTOPUTONRECORD.value()); |
| | | } |
| | | if (a.getStatus().equals(CauseEnums.UNDERCONSIDERATION.getMsg())) { |
| | | cause.setStatus(CauseEnums.UNDERCONSIDERATION.value()); |
| | | } |
| | | if (a.getStatus().equals(CauseEnums.CASECLOSED.getMsg())) { |
| | | cause.setStatus(CauseEnums.CASECLOSED.value()); |
| | | } |
| | | if (a.getStatus().equals(CauseEnums.HASBEENDROPPED.getMsg())) { |
| | | cause.setStatus(CauseEnums.HASBEENDROPPED.value()); |
| | | } |
| | | cause.setCtime(new Date()); |
| | | if (StringUtils.isBlank(a.getUserName())){ |
| | | throw new BusinessException("负责人不允许为空"); |
| | | } |
| | | if (userDao.selectOne(new QueryWrapper<User>().eq("real_name", a.getUserName()))==null){ |
| | | throw new BusinessException("负责人不存在"); |
| | | } |
| | | cause.setUserId(userDao.selectOne(new QueryWrapper<User>().eq("real_name", a.getUserName())).getId()); |
| | | causeDao.insert(cause); |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public Boolean addReportPeople(AddReportDto addReportDto) { |
| | | User user = userDao.selectOne(new LambdaQueryWrapper<User>(User.class).eq(User::getUserIdcard, addReportDto.getIdcard())); |