| | |
| | | package com.ycl.platform.service.impl; |
| | | |
| | | import com.ycl.platform.domain.entity.Region; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ycl.platform.domain.entity.Report; |
| | | import com.ycl.platform.domain.entity.YwPeople; |
| | | import com.ycl.platform.domain.entity.YwPoint; |
| | | import com.ycl.platform.domain.entity.YwUnit; |
| | | import com.ycl.platform.mapper.RegionMapper; |
| | | import com.ycl.platform.domain.form.ReportForm; |
| | | import com.ycl.platform.domain.query.ReportQuery; |
| | | import com.ycl.platform.domain.vo.ReportVO; |
| | | import com.ycl.platform.mapper.ReportMapper; |
| | | import com.ycl.platform.mapper.YwPeopleMapper; |
| | | import com.ycl.platform.mapper.YwPointMapper; |
| | | import com.ycl.platform.mapper.YwUnitMapper; |
| | | import com.ycl.platform.service.ReportService; |
| | | import com.ycl.system.Result; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ycl.platform.domain.form.ReportForm; |
| | | import com.ycl.platform.domain.vo.ReportVO; |
| | | import com.ycl.platform.domain.query.ReportQuery; |
| | | import java.util.List; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.ycl.system.page.PageUtil; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.security.core.context.SecurityContextHolder; |
| | | import com.ycl.utils.SecurityUtils; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.Assert; |
| | | import java.util.ArrayList; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; |
| | | import lombok.RequiredArgsConstructor; |
| | | |
| | | /** |
| | | * 报备 服务实现类 |
| | |
| | | @RequiredArgsConstructor |
| | | public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> implements ReportService { |
| | | |
| | | private final ReportMapper reportMapper; |
| | | private final YwUnitMapper unitMapper; |
| | | private final YwPointMapper ywpointMapper; |
| | | private final YwPeopleMapper peopleMapper; |
| | | private final RegionMapper regionMapper; |
| | | |
| | | /** |
| | | * 添加 |
| | |
| | | */ |
| | | @Override |
| | | public Result add(ReportForm form) { |
| | | form.setPeopleId(1); |
| | | form.setUnitId(2); |
| | | Long userId = SecurityUtils.getUserId(); |
| | | YwPeople people = new LambdaQueryChainWrapper<>(peopleMapper).eq(YwPeople::getUserId, userId).one(); |
| | | form.setPeopleId(people.getId()); |
| | | form.setUnitId(people.getBelongUnit()); |
| | | Report entity = ReportForm.getEntityByForm(form, null); |
| | | entity.setStatus(0); |
| | | if(baseMapper.insert(entity) > 0) { |
| | | return Result.ok("添加成功"); |
| | | } |
| | |
| | | @Override |
| | | public Result page(ReportQuery query) { |
| | | |
| | | if (StringUtils.isNotBlank(query.getPointId())) { |
| | | LambdaQueryWrapper<YwPoint> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.like(YwPoint::getPointName, query.getPointId()); |
| | | query.setPointIdList(ywpointMapper.selectList(queryWrapper).stream().map(YwPoint::getId).collect(Collectors.toList())); |
| | | if(CollectionUtils.isEmpty(query.getPointIdList())) { |
| | | return Result.ok(); |
| | | } |
| | | } |
| | | if (StringUtils.isNotBlank(query.getPeopleId())) { |
| | | LambdaQueryWrapper<YwPeople> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.like(YwPeople::getYwPersonName, query.getPeopleId()); |
| | | query.setPeopleIdList(peopleMapper.selectList(queryWrapper).stream().map(YwPeople::getId).collect(Collectors.toList())); |
| | | if(CollectionUtils.isEmpty(query.getPeopleIdList())) { |
| | | return Result.ok(); |
| | | } |
| | | } |
| | | |
| | | IPage<Report> page = new LambdaQueryChainWrapper<>(baseMapper) |
| | | .eq(StringUtils.isNotBlank(query.getReportType()), Report::getReportType, query.getReportType()) |
| | | .le(Objects.nonNull(query.getBeginCreateTime()), Report::getBeginCreateTime, query.getBeginCreateTime()) |
| | | .ge(Objects.nonNull(query.getEndCreateTime()), Report::getEndCreateTime, query.getEndCreateTime()) |
| | | .in(!CollectionUtils.isEmpty(query.getPointIdList()), Report::getPointId, query.getPointIdList()) |
| | | .in(!CollectionUtils.isEmpty(query.getPeopleIdList()), Report::getPeopleId, query.getPeopleIdList()) |
| | | .orderByDesc(Report::getCreateTime) |
| | | .page(PageUtil.getPage(query, Report.class)); |
| | | |
| | |
| | | vo.setUnitName(unit.getUnitName()); |
| | | YwPeople ywPeople = peopleMapper.selectById(vo.getPeopleId()); |
| | | vo.setPeopleName(ywPeople.getYwPersonName()); |
| | | Region region = regionMapper.selectById(vo.getPointId()); |
| | | vo.setPointName(region.getFullName()); |
| | | YwPoint ywPoint = ywpointMapper.selectById(vo.getPointId()); |
| | | vo.setPointName(ywPoint.getPointName()); |
| | | return vo; |
| | | } |
| | | ) |