123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305 |
- package cn.cslg.pas.service.business;
- import cn.cslg.pas.common.dto.business.ReportAffairDTO;
- import cn.cslg.pas.common.dto.invalidDTO.AddAdminProceedDTO;
- import cn.cslg.pas.common.dto.invalidDTO.AddJudgmentDTO;
- import cn.cslg.pas.common.dto.invalidDTO.UpdateAdminProceedDTO;
- import cn.cslg.pas.common.dto.invalidDTO.UpdateJudgmentDTO;
- import cn.cslg.pas.common.model.report.ExtraEmailDTO;
- import cn.cslg.pas.common.model.report.MailMessageDTO;
- import cn.cslg.pas.common.vo.invalidVO.AdminProceedVO;
- import cn.cslg.pas.common.vo.invalidVO.JudgementVO;
- import cn.cslg.pas.common.vo.invalidVO.OralTrailVO;
- import cn.cslg.pas.domain.BaseEntity;
- import cn.cslg.pas.domain.business.*;
- import cn.cslg.pas.exception.XiaoShiException;
- import cn.cslg.pas.mapper.AdminProceedMapper;
- import cn.cslg.pas.service.MailSendService;
- import cn.cslg.pas.service.report.SendReportMailService;
- import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
- import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
- import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
- import lombok.extern.slf4j.Slf4j;
- import org.apache.commons.lang3.ObjectUtils;
- import org.apache.commons.lang3.StringUtils;
- import org.springframework.beans.BeanUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import org.springframework.util.CollectionUtils;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.stream.Collectors;
- /**
- * @Author xiexiang
- * @Date 2023/12/28
- */
- @Slf4j
- @Service
- public class AdminProceedService extends ServiceImpl<AdminProceedMapper, AdminProceed> {
- @Autowired
- private ReportAffairService reportAffairService;
- @Autowired
- private AssoReportAffairFileService assoReportAffairFileService;
- @Autowired
- private CourtOrderService courtOrderService;
- @Autowired
- private SendReportMailService sendReportMailService;
- @Autowired
- private MailSendService mailSendService;
- @Autowired
- private InvalidRequestFileService invalidRequestFileService;
- /**
- * 上传行政诉讼书
- * @param addDto
- * @return
- */
- public Integer add(AddAdminProceedDTO addDto){
- if (addDto == null) {
- throw new XiaoShiException("入参为空");
- }
- Integer projectId = addDto.getProjectId();
- if (projectId == null) {
- throw new XiaoShiException("报告id为空");
- }
- if (ObjectUtils.isEmpty(addDto.getAssoCasePhaseId())) {
- throw new XiaoShiException("案件流程阶段id为空");
- }
- //1. 首先上传报告事务,拿到报告事务id
- ReportAffairDTO reportAffairDTO = new ReportAffairDTO();
- reportAffairDTO.setProjectId(projectId);
- //发生时间是口审时间
- reportAffairDTO.setOccurredTime(addDto.getProceedingTime());
- //备注
- reportAffairDTO.setDescription(addDto.getDescription());
- reportAffairDTO.setAssoCasePhaseId(addDto.getAssoCasePhaseId());
- Integer reportAffairId = reportAffairService.addReportAffair(reportAffairDTO);
- if (reportAffairId == null) {
- throw new XiaoShiException("上传报告事务失败");
- }
- //2. 上传行政诉讼
- AdminProceed adminLitigation = new AdminProceed();
- adminLitigation.setConclusion(addDto.getConclusion());
- adminLitigation.setReportAffairId(reportAffairId);
- adminLitigation.insert();
- //3. 添加报告事务与文件关联
- List<String> fileGuids = addDto.getFileGuids();
- if (fileGuids != null && !fileGuids.isEmpty()) {
- List<AssoReportAffairFile> assoReportAffairFiles = new ArrayList<>();
- fileGuids.forEach(item -> {
- AssoReportAffairFile assoReportAffairFile = new AssoReportAffairFile();
- assoReportAffairFile.setReportAffairId(reportAffairId);
- assoReportAffairFile.setFileGuid(item);
- assoReportAffairFiles.add(assoReportAffairFile);
- });
- assoReportAffairFileService.saveBatch(assoReportAffairFiles);
- }
- if (addDto.getIfSendEmail()) {
- sendReportMailService.finalSendEmail(projectId, fileGuids, addDto.getExtraEmailDTOS(),reportAffairDTO);
- }
- return reportAffairId;
- }
- /**
- * 查询
- * @param reportAffairId
- * @return
- */
- public AdminProceedVO getAdminProceed(Integer reportAffairId) {
- LambdaQueryWrapper<AdminProceed> queryWrapper = new LambdaQueryWrapper<>();
- queryWrapper.eq(AdminProceed::getReportAffairId, reportAffairId);
- AdminProceed adminProceed = this.getOne(queryWrapper, false);
- AdminProceedVO adminProceedVO = new AdminProceedVO();
- if (adminProceed != null) {
- BeanUtils.copyProperties(adminProceed, adminProceedVO);
- adminProceedVO.setProceedingId(adminProceed.getId());
- }
- ReportAffair reportAffair = reportAffairService.getById(reportAffairId);
- adminProceedVO.setProceedingTime(reportAffair.getOccurredTime());
- return adminProceedVO;
- }
- /**
- * 更新行政诉讼书
- * @param updateDTO
- * @return
- */
- public Integer update(UpdateAdminProceedDTO updateDTO){
- if (updateDTO == null) {
- throw new XiaoShiException("入参为空");
- }
- Integer projectId = updateDTO.getProjectId();
- Integer id = updateDTO.getProceedingId();
- if (id == null) {
- throw new XiaoShiException("id为空");
- }
- if (projectId == null) {
- throw new XiaoShiException("报告id为空");
- }
- if (ObjectUtils.isEmpty(updateDTO.getAssoCasePhaseId())) {
- throw new XiaoShiException("案件流程阶段id为空");
- }
- //1. 根据id查出行政记录
- AdminProceed al = this.getById(id);
- if (al == null) {
- throw new XiaoShiException("oralTrail查询错误");
- }
- BeanUtils.copyProperties(updateDTO, al);
- al.updateById();
- Integer reportAffairId = al.getReportAffairId();
- //2. 拿到报告事务id,获取报告事务
- ReportAffair reportAffair = reportAffairService.getById(reportAffairId);
- reportAffair.setProjectId(projectId);
- //发生时间是无效请求日
- reportAffair.setOccurredTime(updateDTO.getProceedingTime());
- //备注
- reportAffair.setDescription(updateDTO.getDescription());
- reportAffair.setAssoCasePhaseId(updateDTO.getAssoCasePhaseId());
- reportAffair.updateById();
- //3. 更新报告事务与文件关联
- List<String> fileGuids = updateDTO.getFileGuids();
- assoReportAffairFileService.updateAffairFile(reportAffairId, fileGuids);
- if (updateDTO.getIfSendEmail()) {
- ReportAffairDTO reportAffairDTO =new ReportAffairDTO();
- reportAffairDTO.setAssoCasePhaseId(reportAffair.getAssoCasePhaseId());
- sendReportMailService.finalSendEmail(projectId, fileGuids, updateDTO.getExtraEmailDTOS(),reportAffairDTO);
- }
- return reportAffairId;
- }
- /**
- * 上传行政诉讼判决书
- * @param addJudgmentDTO
- * @return
- */
- public Integer addJudgment(AddJudgmentDTO addJudgmentDTO){
- if (addJudgmentDTO == null) {
- throw new XiaoShiException("入参为空");
- }
- Integer projectId = addJudgmentDTO.getProjectId();
- if (projectId == null) {
- throw new XiaoShiException("报告id为空");
- }
- if (ObjectUtils.isEmpty(addJudgmentDTO.getAssoCasePhaseId())) {
- throw new XiaoShiException("案件流程阶段id为空");
- }
- //1. 首先上传报告事务,拿到报告事务id
- ReportAffairDTO reportAffairDTO = new ReportAffairDTO();
- reportAffairDTO.setProjectId(projectId);
- //发生时间是口审时间
- reportAffairDTO.setOccurredTime(addJudgmentDTO.getJudgmentTime());
- //备注
- reportAffairDTO.setDescription(addJudgmentDTO.getDescription());
- reportAffairDTO.setAssoCasePhaseId(addJudgmentDTO.getAssoCasePhaseId());
- Integer reportAffairId = reportAffairService.addReportAffair(reportAffairDTO);
- if (reportAffairId == null) {
- throw new XiaoShiException("上传报告事务失败");
- }
- //2.创建法院判决书
- CourtOrder courtOrder = new CourtOrder();
- courtOrder.setConclusion(addJudgmentDTO.getConclusion());
- courtOrder.setFirstInstanceStageReason(addJudgmentDTO.getFirstInstanceStageReason());
- courtOrder.setReportAffairId(reportAffairId);
- courtOrder.insert();
- //同步报告官限
- invalidRequestFileService.getCommonMethod(projectId, addJudgmentDTO.getAssoCasePhaseId());
- //3. 添加报告事务与文件关联
- List<String> fileGuids = addJudgmentDTO.getFileGuids();
- if (fileGuids != null && !fileGuids.isEmpty()) {
- List<AssoReportAffairFile> assoReportAffairFiles = new ArrayList<>();
- fileGuids.forEach(item -> {
- AssoReportAffairFile assoReportAffairFile = new AssoReportAffairFile();
- assoReportAffairFile.setReportAffairId(reportAffairId);
- assoReportAffairFile.setFileGuid(item);
- assoReportAffairFiles.add(assoReportAffairFile);
- });
- assoReportAffairFileService.saveBatch(assoReportAffairFiles);
- }
- if (addJudgmentDTO.getIfSendEmail()) {
- sendReportMailService.finalSendEmail(projectId, fileGuids, addJudgmentDTO.getExtraEmailDTOS(),reportAffairDTO);
- }
- return reportAffairId;
- }
- /**
- * 更新行政诉讼判决书
- * @param updateJudgmentDTO
- * @return
- */
- public Integer updateJudgment(UpdateJudgmentDTO updateJudgmentDTO){
- if (updateJudgmentDTO == null) {
- throw new XiaoShiException("入参为空");
- }
- Integer projectId = updateJudgmentDTO.getProjectId();
- Integer reportAffairId = updateJudgmentDTO.getJudgmentId();
- if (reportAffairId == null) {
- throw new XiaoShiException("id为空");
- }
- if (projectId == null) {
- throw new XiaoShiException("报告id为空");
- }
- if (ObjectUtils.isEmpty(updateJudgmentDTO.getAssoCasePhaseId())) {
- throw new XiaoShiException("案件流程阶段id为空");
- }
- //1.拿到报告事务id,获取法院判别书,并更新
- List<CourtOrder> courtOrders = courtOrderService.list(new LambdaQueryWrapper<CourtOrder>()
- .eq(CourtOrder::getReportAffairId, reportAffairId)
- .orderByDesc(BaseEntity::getId));
- if (!CollectionUtils.isEmpty(courtOrders)) {
- CourtOrder courtOrder = courtOrders.get(0);
- CourtOrder court = courtOrderService.getById(courtOrder.getId());
- court.setConclusion(updateJudgmentDTO.getConclusion());
- court.setFirstInstanceStageReason(updateJudgmentDTO.getFirstInstanceStageReason());
- court.updateById();
- }
- //2. 拿到报告事务id,获取报告事务
- ReportAffair reportAffair = reportAffairService.getById(reportAffairId);
- reportAffair.setProjectId(projectId);
- //发生时间是无效请求日
- reportAffair.setOccurredTime(updateJudgmentDTO.getJudgmentTime());
- //备注
- reportAffair.setDescription(updateJudgmentDTO.getDescription());
- reportAffair.setAssoCasePhaseId(updateJudgmentDTO.getAssoCasePhaseId());
- reportAffair.updateById();
- //同步报告官限
- invalidRequestFileService.getCommonMethod(projectId, updateJudgmentDTO.getAssoCasePhaseId());
- //3. 更新报告事务与文件关联
- List<String> fileGuids = updateJudgmentDTO.getFileGuids();
- assoReportAffairFileService.updateAffairFile(reportAffairId, fileGuids);
- if (updateJudgmentDTO.getIfSendEmail()) {
- ReportAffairDTO reportAffairDTO =new ReportAffairDTO();
- reportAffairDTO.setAssoCasePhaseId(reportAffair.getAssoCasePhaseId());
- sendReportMailService.finalSendEmail(projectId, fileGuids, updateJudgmentDTO.getExtraEmailDTOS(),reportAffairDTO);
- }
- return reportAffairId;
- }
- /**
- * 查询行政诉讼判决书
- * @param reportAffairId
- * @return
- */
- public JudgementVO getJudgment(Integer reportAffairId) {
- ReportAffair reportAffair = reportAffairService.getById(reportAffairId);
- JudgementVO judgementVO = new JudgementVO();
- if (reportAffair != null) {
- BeanUtils.copyProperties(reportAffair, judgementVO);
- judgementVO.setJudgmentId(reportAffair.getId());
- judgementVO.setJudgmentTime(reportAffair.getOccurredTime());
- }
- return judgementVO;
- }
- }
|