| | |
| | | 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.Date; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | 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 |
| | | public void deleteCause(Integer id) { |
| | | causeDao.deleteById(id); |
| | | } |
| | | |
| | | @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) { |
| | | if (StringUtils.isNotBlank(data.getName())&&StringUtils.isNotBlank(data.getUserName())){ |
| | | 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("负责人不存在"); |
| | | } |
| | | Integer id = userDao.selectOne(new QueryWrapper<User>().eq("real_name", a.getUserName())).getId(); |
| | | cause.setUserId(id); |
| | | causeService.save(cause); |
| | | Group group = new Group(); |
| | | group.setCtime(new Date()); |
| | | group.setUserId(id); |
| | | group.setGroupName(a.getName()); |
| | | group.setCauseId(cause.getId()); |
| | | groupDao.insert(group); |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | |
| | | .setCauseId(groupDao.selectOne(new QueryWrapper<Group>().eq("id", addReportDto.getGroupId())).getCauseId()); |
| | | return reportDao.insert(report) > 0; |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, String>> getCauseIdAndName() { |
| | | ArrayList<Map<String, String>> maps = new ArrayList<>(); |
| | | causeDao.selectList(null).stream().forEach(a -> { |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("id", a.getId().toString()); |
| | | map.put("name", a.getName()); |
| | | maps.add(map); |
| | | }); |
| | | return maps; |
| | | } |
| | | } |