AdminProceedService.java 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. package cn.cslg.pas.service.business;
  2. import cn.cslg.pas.common.dto.business.ReportAffairDTO;
  3. import cn.cslg.pas.common.dto.invalidDTO.AddAdminProceedDTO;
  4. import cn.cslg.pas.common.dto.invalidDTO.AddJudgmentDTO;
  5. import cn.cslg.pas.common.dto.invalidDTO.UpdateAdminProceedDTO;
  6. import cn.cslg.pas.common.dto.invalidDTO.UpdateJudgmentDTO;
  7. import cn.cslg.pas.common.model.report.ExtraEmailDTO;
  8. import cn.cslg.pas.common.model.report.MailMessageDTO;
  9. import cn.cslg.pas.common.vo.invalidVO.AdminProceedVO;
  10. import cn.cslg.pas.common.vo.invalidVO.JudgementVO;
  11. import cn.cslg.pas.common.vo.invalidVO.OralTrailVO;
  12. import cn.cslg.pas.domain.BaseEntity;
  13. import cn.cslg.pas.domain.business.*;
  14. import cn.cslg.pas.exception.XiaoShiException;
  15. import cn.cslg.pas.mapper.AdminProceedMapper;
  16. import cn.cslg.pas.service.MailSendService;
  17. import cn.cslg.pas.service.report.SendReportMailService;
  18. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  19. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  20. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  21. import lombok.extern.slf4j.Slf4j;
  22. import org.apache.commons.lang3.ObjectUtils;
  23. import org.apache.commons.lang3.StringUtils;
  24. import org.springframework.beans.BeanUtils;
  25. import org.springframework.beans.factory.annotation.Autowired;
  26. import org.springframework.stereotype.Service;
  27. import org.springframework.util.CollectionUtils;
  28. import java.util.ArrayList;
  29. import java.util.List;
  30. import java.util.stream.Collectors;
  31. /**
  32. * @Author xiexiang
  33. * @Date 2023/12/28
  34. */
  35. @Slf4j
  36. @Service
  37. public class AdminProceedService extends ServiceImpl<AdminProceedMapper, AdminProceed> {
  38. @Autowired
  39. private ReportAffairService reportAffairService;
  40. @Autowired
  41. private AssoReportAffairFileService assoReportAffairFileService;
  42. @Autowired
  43. private CourtOrderService courtOrderService;
  44. @Autowired
  45. private SendReportMailService sendReportMailService;
  46. @Autowired
  47. private MailSendService mailSendService;
  48. @Autowired
  49. private InvalidRequestFileService invalidRequestFileService;
  50. /**
  51. * 上传行政诉讼书
  52. * @param addDto
  53. * @return
  54. */
  55. public Integer add(AddAdminProceedDTO addDto){
  56. if (addDto == null) {
  57. throw new XiaoShiException("入参为空");
  58. }
  59. Integer projectId = addDto.getProjectId();
  60. if (projectId == null) {
  61. throw new XiaoShiException("报告id为空");
  62. }
  63. if (ObjectUtils.isEmpty(addDto.getAssoCasePhaseId())) {
  64. throw new XiaoShiException("案件流程阶段id为空");
  65. }
  66. //1. 首先上传报告事务,拿到报告事务id
  67. ReportAffairDTO reportAffairDTO = new ReportAffairDTO();
  68. reportAffairDTO.setProjectId(projectId);
  69. //发生时间是口审时间
  70. reportAffairDTO.setOccurredTime(addDto.getProceedingTime());
  71. //备注
  72. reportAffairDTO.setDescription(addDto.getDescription());
  73. reportAffairDTO.setAssoCasePhaseId(addDto.getAssoCasePhaseId());
  74. Integer reportAffairId = reportAffairService.addReportAffair(reportAffairDTO);
  75. if (reportAffairId == null) {
  76. throw new XiaoShiException("上传报告事务失败");
  77. }
  78. //2. 上传行政诉讼
  79. AdminProceed adminLitigation = new AdminProceed();
  80. adminLitigation.setConclusion(addDto.getConclusion());
  81. adminLitigation.setReportAffairId(reportAffairId);
  82. adminLitigation.insert();
  83. //3. 添加报告事务与文件关联
  84. List<String> fileGuids = addDto.getFileGuids();
  85. if (fileGuids != null && !fileGuids.isEmpty()) {
  86. List<AssoReportAffairFile> assoReportAffairFiles = new ArrayList<>();
  87. fileGuids.forEach(item -> {
  88. AssoReportAffairFile assoReportAffairFile = new AssoReportAffairFile();
  89. assoReportAffairFile.setReportAffairId(reportAffairId);
  90. assoReportAffairFile.setFileGuid(item);
  91. assoReportAffairFiles.add(assoReportAffairFile);
  92. });
  93. assoReportAffairFileService.saveBatch(assoReportAffairFiles);
  94. }
  95. if (addDto.getIfSendEmail()) {
  96. sendReportMailService.finalSendEmail(projectId, fileGuids, addDto.getExtraEmailDTOS(),reportAffairDTO);
  97. }
  98. return reportAffairId;
  99. }
  100. /**
  101. * 查询
  102. * @param reportAffairId
  103. * @return
  104. */
  105. public AdminProceedVO getAdminProceed(Integer reportAffairId) {
  106. LambdaQueryWrapper<AdminProceed> queryWrapper = new LambdaQueryWrapper<>();
  107. queryWrapper.eq(AdminProceed::getReportAffairId, reportAffairId);
  108. AdminProceed adminProceed = this.getOne(queryWrapper, false);
  109. AdminProceedVO adminProceedVO = new AdminProceedVO();
  110. if (adminProceed != null) {
  111. BeanUtils.copyProperties(adminProceed, adminProceedVO);
  112. adminProceedVO.setProceedingId(adminProceed.getId());
  113. }
  114. ReportAffair reportAffair = reportAffairService.getById(reportAffairId);
  115. adminProceedVO.setProceedingTime(reportAffair.getOccurredTime());
  116. return adminProceedVO;
  117. }
  118. /**
  119. * 更新行政诉讼书
  120. * @param updateDTO
  121. * @return
  122. */
  123. public Integer update(UpdateAdminProceedDTO updateDTO){
  124. if (updateDTO == null) {
  125. throw new XiaoShiException("入参为空");
  126. }
  127. Integer projectId = updateDTO.getProjectId();
  128. Integer id = updateDTO.getProceedingId();
  129. if (id == null) {
  130. throw new XiaoShiException("id为空");
  131. }
  132. if (projectId == null) {
  133. throw new XiaoShiException("报告id为空");
  134. }
  135. if (ObjectUtils.isEmpty(updateDTO.getAssoCasePhaseId())) {
  136. throw new XiaoShiException("案件流程阶段id为空");
  137. }
  138. //1. 根据id查出行政记录
  139. AdminProceed al = this.getById(id);
  140. if (al == null) {
  141. throw new XiaoShiException("oralTrail查询错误");
  142. }
  143. BeanUtils.copyProperties(updateDTO, al);
  144. al.updateById();
  145. Integer reportAffairId = al.getReportAffairId();
  146. //2. 拿到报告事务id,获取报告事务
  147. ReportAffair reportAffair = reportAffairService.getById(reportAffairId);
  148. reportAffair.setProjectId(projectId);
  149. //发生时间是无效请求日
  150. reportAffair.setOccurredTime(updateDTO.getProceedingTime());
  151. //备注
  152. reportAffair.setDescription(updateDTO.getDescription());
  153. reportAffair.setAssoCasePhaseId(updateDTO.getAssoCasePhaseId());
  154. reportAffair.updateById();
  155. //3. 更新报告事务与文件关联
  156. List<String> fileGuids = updateDTO.getFileGuids();
  157. assoReportAffairFileService.updateAffairFile(reportAffairId, fileGuids);
  158. if (updateDTO.getIfSendEmail()) {
  159. ReportAffairDTO reportAffairDTO =new ReportAffairDTO();
  160. reportAffairDTO.setAssoCasePhaseId(reportAffair.getAssoCasePhaseId());
  161. sendReportMailService.finalSendEmail(projectId, fileGuids, updateDTO.getExtraEmailDTOS(),reportAffairDTO);
  162. }
  163. return reportAffairId;
  164. }
  165. /**
  166. * 上传行政诉讼判决书
  167. * @param addJudgmentDTO
  168. * @return
  169. */
  170. public Integer addJudgment(AddJudgmentDTO addJudgmentDTO){
  171. if (addJudgmentDTO == null) {
  172. throw new XiaoShiException("入参为空");
  173. }
  174. Integer projectId = addJudgmentDTO.getProjectId();
  175. if (projectId == null) {
  176. throw new XiaoShiException("报告id为空");
  177. }
  178. if (ObjectUtils.isEmpty(addJudgmentDTO.getAssoCasePhaseId())) {
  179. throw new XiaoShiException("案件流程阶段id为空");
  180. }
  181. //1. 首先上传报告事务,拿到报告事务id
  182. ReportAffairDTO reportAffairDTO = new ReportAffairDTO();
  183. reportAffairDTO.setProjectId(projectId);
  184. //发生时间是口审时间
  185. reportAffairDTO.setOccurredTime(addJudgmentDTO.getJudgmentTime());
  186. //备注
  187. reportAffairDTO.setDescription(addJudgmentDTO.getDescription());
  188. reportAffairDTO.setAssoCasePhaseId(addJudgmentDTO.getAssoCasePhaseId());
  189. Integer reportAffairId = reportAffairService.addReportAffair(reportAffairDTO);
  190. if (reportAffairId == null) {
  191. throw new XiaoShiException("上传报告事务失败");
  192. }
  193. //2.创建法院判决书
  194. CourtOrder courtOrder = new CourtOrder();
  195. courtOrder.setConclusion(addJudgmentDTO.getConclusion());
  196. courtOrder.setFirstInstanceStageReason(addJudgmentDTO.getFirstInstanceStageReason());
  197. courtOrder.setReportAffairId(reportAffairId);
  198. courtOrder.insert();
  199. //同步报告官限
  200. invalidRequestFileService.getCommonMethod(projectId, addJudgmentDTO.getAssoCasePhaseId());
  201. //3. 添加报告事务与文件关联
  202. List<String> fileGuids = addJudgmentDTO.getFileGuids();
  203. if (fileGuids != null && !fileGuids.isEmpty()) {
  204. List<AssoReportAffairFile> assoReportAffairFiles = new ArrayList<>();
  205. fileGuids.forEach(item -> {
  206. AssoReportAffairFile assoReportAffairFile = new AssoReportAffairFile();
  207. assoReportAffairFile.setReportAffairId(reportAffairId);
  208. assoReportAffairFile.setFileGuid(item);
  209. assoReportAffairFiles.add(assoReportAffairFile);
  210. });
  211. assoReportAffairFileService.saveBatch(assoReportAffairFiles);
  212. }
  213. if (addJudgmentDTO.getIfSendEmail()) {
  214. sendReportMailService.finalSendEmail(projectId, fileGuids, addJudgmentDTO.getExtraEmailDTOS(),reportAffairDTO);
  215. }
  216. return reportAffairId;
  217. }
  218. /**
  219. * 更新行政诉讼判决书
  220. * @param updateJudgmentDTO
  221. * @return
  222. */
  223. public Integer updateJudgment(UpdateJudgmentDTO updateJudgmentDTO){
  224. if (updateJudgmentDTO == null) {
  225. throw new XiaoShiException("入参为空");
  226. }
  227. Integer projectId = updateJudgmentDTO.getProjectId();
  228. Integer reportAffairId = updateJudgmentDTO.getJudgmentId();
  229. if (reportAffairId == null) {
  230. throw new XiaoShiException("id为空");
  231. }
  232. if (projectId == null) {
  233. throw new XiaoShiException("报告id为空");
  234. }
  235. if (ObjectUtils.isEmpty(updateJudgmentDTO.getAssoCasePhaseId())) {
  236. throw new XiaoShiException("案件流程阶段id为空");
  237. }
  238. //1.拿到报告事务id,获取法院判别书,并更新
  239. List<CourtOrder> courtOrders = courtOrderService.list(new LambdaQueryWrapper<CourtOrder>()
  240. .eq(CourtOrder::getReportAffairId, reportAffairId)
  241. .orderByDesc(BaseEntity::getId));
  242. if (!CollectionUtils.isEmpty(courtOrders)) {
  243. CourtOrder courtOrder = courtOrders.get(0);
  244. CourtOrder court = courtOrderService.getById(courtOrder.getId());
  245. court.setConclusion(updateJudgmentDTO.getConclusion());
  246. court.setFirstInstanceStageReason(updateJudgmentDTO.getFirstInstanceStageReason());
  247. court.updateById();
  248. }
  249. //2. 拿到报告事务id,获取报告事务
  250. ReportAffair reportAffair = reportAffairService.getById(reportAffairId);
  251. reportAffair.setProjectId(projectId);
  252. //发生时间是无效请求日
  253. reportAffair.setOccurredTime(updateJudgmentDTO.getJudgmentTime());
  254. //备注
  255. reportAffair.setDescription(updateJudgmentDTO.getDescription());
  256. reportAffair.setAssoCasePhaseId(updateJudgmentDTO.getAssoCasePhaseId());
  257. reportAffair.updateById();
  258. //同步报告官限
  259. invalidRequestFileService.getCommonMethod(projectId, updateJudgmentDTO.getAssoCasePhaseId());
  260. //3. 更新报告事务与文件关联
  261. List<String> fileGuids = updateJudgmentDTO.getFileGuids();
  262. assoReportAffairFileService.updateAffairFile(reportAffairId, fileGuids);
  263. if (updateJudgmentDTO.getIfSendEmail()) {
  264. ReportAffairDTO reportAffairDTO =new ReportAffairDTO();
  265. reportAffairDTO.setAssoCasePhaseId(reportAffair.getAssoCasePhaseId());
  266. sendReportMailService.finalSendEmail(projectId, fileGuids, updateJudgmentDTO.getExtraEmailDTOS(),reportAffairDTO);
  267. }
  268. return reportAffairId;
  269. }
  270. /**
  271. * 查询行政诉讼判决书
  272. * @param reportAffairId
  273. * @return
  274. */
  275. public JudgementVO getJudgment(Integer reportAffairId) {
  276. ReportAffair reportAffair = reportAffairService.getById(reportAffairId);
  277. JudgementVO judgementVO = new JudgementVO();
  278. if (reportAffair != null) {
  279. BeanUtils.copyProperties(reportAffair, judgementVO);
  280. judgementVO.setJudgmentId(reportAffair.getId());
  281. judgementVO.setJudgmentTime(reportAffair.getOccurredTime());
  282. }
  283. return judgementVO;
  284. }
  285. }