123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- package cn.cslg.pas.service.novelty;
- import cn.cslg.pas.common.model.novelty.LitigationDTO;
- import cn.cslg.pas.common.model.novelty.LitigationReVO;
- import cn.cslg.pas.common.model.novelty.LitigationVO;
- import cn.cslg.pas.domain.business.CourtOrder;
- import cn.cslg.pas.domain.business.ReportAffair;
- import cn.cslg.pas.exception.ExceptionEnum;
- import cn.cslg.pas.exception.XiaoShiException;
- import cn.cslg.pas.service.business.CourtOrderService;
- import cn.cslg.pas.service.business.ReportAffairService;
- import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
- import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
- import cn.cslg.pas.domain.business.novelty.Litigation;
- import cn.cslg.pas.mapper.novelty.LitigationMapper;
- import lombok.RequiredArgsConstructor;
- import org.springframework.beans.BeanUtils;
- import org.springframework.stereotype.Service;
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.List;
- import java.util.stream.Collectors;
- /**
- * @author admin
- * @description 针对表【litigation(行政诉讼表)】的数据库操作Service实现
- * @createDate 2025-02-27 10:49:21
- */
- @Service
- @RequiredArgsConstructor
- public class LitigationService extends ServiceImpl<LitigationMapper, Litigation> {
- private final ReportAffairService reportAffairService;
- private final CourtOrderService courtOrderService;
- public Litigation addLitigation(LitigationDTO litigationDTO) {
- Litigation litigation = new Litigation();
- BeanUtils.copyProperties(litigationDTO, litigation);
- litigation.insert();
- return litigation;
- }
- public Litigation updateLitigation(LitigationDTO litigationDTO, Litigation litigation) {
- Litigation litigation1 = new Litigation();
- BeanUtils.copyProperties(litigationDTO, litigation1);
- litigation1.setCreateId(litigation.getCreateId());
- litigation1.setCreateTime(litigation.getCreateTime());
- litigation1.setId(litigation.getId());
- litigation1.updateById();
- return litigation;
- }
- public Litigation addOrUpdateLitigation(LitigationDTO litigationDTO) {
- Integer projectId = litigationDTO.getProjectId();
- Integer type = litigationDTO.getType();
- if (projectId == null || type == null) {
- throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "未传入必要参数");
- }
- LambdaQueryWrapper<Litigation> queryWrapper = new LambdaQueryWrapper<>();
- queryWrapper.eq(Litigation::getProjectId, projectId)
- .eq(Litigation::getType, type);
- Litigation litigation = this.getOne(queryWrapper, false);
- if (litigation == null) {
- return this.addLitigation(litigationDTO);
- } else {
- return this.updateLitigation(litigationDTO, litigation);
- }
- }
- public LitigationReVO queryLitigation(LitigationDTO litigationDTO) {
- LitigationReVO litigationReVO = new LitigationReVO();
- Integer projectId = litigationDTO.getProjectId();
- LambdaQueryWrapper<Litigation> queryWrapper = new LambdaQueryWrapper<>();
- queryWrapper.eq(Litigation::getProjectId, projectId);
- List<Litigation> list = this.list(queryWrapper);
- litigationReVO = this.loadLitigation(list, projectId);
- return litigationReVO;
- }
- public LitigationReVO loadLitigation(List<Litigation> list, Integer projectId) {
- LitigationReVO litigationReVO = new LitigationReVO();
- if (list.size() == 0) {
- return litigationReVO;
- }
- List<LitigationVO> litigationVOS = new ArrayList<>();
- list.forEach(item -> {
- LitigationVO litigationVO = new LitigationVO();
- BeanUtils.copyProperties(item, litigationVO);
- litigationVOS.add(litigationVO);
- });
- this.loadResultByAffair(projectId, litigationVOS);
- litigationVOS.forEach(item -> {
- if (item.getType().equals(1)) {
- litigationReVO.setLitigationVO1(item);
- } else {
- litigationReVO.setLitigationVO2(item);
- }
- });
- return litigationReVO;
- }
- public List<LitigationVO> loadResultByAffair(Integer projectId, List<LitigationVO> list) {
- if (list.size() == 0) {
- return list;
- }
- Integer litigationType1 = 16;
- Integer litigationType2 = 26;
- LambdaQueryWrapper<ReportAffair> queryWrapper = new LambdaQueryWrapper<>();
- queryWrapper.eq(ReportAffair::getProjectId, projectId)
- .in(ReportAffair::getAssoCasePhaseId, Arrays.asList(litigationType1, litigationType2));
- List<ReportAffair> reportAffairs = reportAffairService.list(queryWrapper);
- if (reportAffairs == null || reportAffairs.size() == 0) {
- return list;
- }
- List<Integer> reportAffairIds = reportAffairs.stream().map(ReportAffair::getId).collect(Collectors.toList());
- List<CourtOrder> courtOrders = new ArrayList<>();
- if (reportAffairIds.size() > 0) {
- LambdaQueryWrapper<CourtOrder> queryWrapper1 = new LambdaQueryWrapper<>();
- queryWrapper1.in(CourtOrder::getReportAffairId, reportAffairIds);
- courtOrders = courtOrderService.list(queryWrapper1);
- }
- if (courtOrders.size() == 0) {
- return list;
- }
- List<CourtOrder> finalCourtOrders = courtOrders;
- list.forEach(item -> {
- Integer affairType = litigationType1;
- if (item.getType().equals(1)) {
- affairType = litigationType1;
- } else {
- affairType = litigationType2;
- }
- Integer finalType = affairType;
- ReportAffair reportAffair = reportAffairs.stream().filter(tem -> finalType.equals(tem.getAssoCasePhaseId())).findFirst().orElse(null);
- if (reportAffair != null) {
- Integer temAffairId = reportAffair.getId();
- CourtOrder courtOrder = finalCourtOrders.stream().filter(tem -> tem.getReportAffairId().equals(temAffairId)).findFirst().orElse(null);
- if (courtOrder != null) {
- item.setConclusion(courtOrder.getConclusion());
- }
- }
- });
- return list;
- }
- }
|