package com.ycl.service.caseHandler.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ycl.bo.AdminUserDetails; import com.ycl.controller.video.common.constant.BaseCaseStatus; import com.ycl.controller.video.common.constant.StepName; import com.ycl.dto.dispatch.UploadDisposingResultParam; import com.ycl.entity.caseHandler.*; import com.ycl.entity.resources.ImageResources; import com.ycl.exception.ApiException; import com.ycl.mapper.caseHandler.BaseCaseMapper; import com.ycl.mapper.caseHandler.DisposeRecordMapper; import com.ycl.mapper.caseHandler.WorkflowConfigStepMapper; import com.ycl.service.caseHandler.*; import com.ycl.service.resources.IImageResourcesService; import com.ycl.vo.MyBacklogVO; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.List; /** *

* 处置流程记录 服务实现类 *

* * @author wl * @since 2022-09-24 */ @Service public class DisposeRecordServiceImpl extends ServiceImpl implements IDisposeRecordService { @Resource BaseCaseMapper baseCaseMapper; @Resource DisposeRecordMapper disposeRecordMapper; @Resource WorkflowConfigStepMapper workflowConfigStepMapper; @Autowired IInvestigationService iInvestigationService; @Autowired IArrivalSituationService iArrivalSituationService; @Autowired IPartyInfoService iPartyInfoService; @Autowired IWritService iWritService; @Autowired IBaseCaseService baseCaseService; @Autowired IDisposeRecordService iDisposeRecordService; @Autowired IImageResourcesService iImageResourcesService; @Override public Page listMyTask(Page page, String num, Long userId) { return disposeRecordMapper.selectMyBackList(page,userId, num); } @Override @Transactional(rollbackFor = Exception.class) public Boolean saveOrUpdateUpload(UploadDisposingResultParam uploadDisposingResultParam) { AdminUserDetails user = (AdminUserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); List list = iArrivalSituationService.list(new LambdaQueryWrapper().eq(ArrivalSituation::getBaseCaseId, uploadDisposingResultParam.getCaseId())); if (!list.isEmpty()) { //当事人 PartyInfo partyInfo = new PartyInfo(); BeanUtils.copyProperties(uploadDisposingResultParam, partyInfo); partyInfo.setId(uploadDisposingResultParam.getPartyInfoId()); iPartyInfoService.updateById(partyInfo); //调查取证 Investigation investigation = new Investigation(); BeanUtils.copyProperties(uploadDisposingResultParam, investigation); investigation.setBaseCaseId(uploadDisposingResultParam.getCaseId()); investigation.setPartyId(partyInfo.getId()); investigation.setInvestigationTime(LocalDateTime.parse(uploadDisposingResultParam.getInvestigationTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); investigation.setId(uploadDisposingResultParam.getInvestigationId()); iInvestigationService.updateById(investigation); //到达 ArrivalSituation arrivalSituation = new ArrivalSituation(); BeanUtils.copyProperties(uploadDisposingResultParam, arrivalSituation); arrivalSituation.setBaseCaseId(uploadDisposingResultParam.getCaseId()); arrivalSituation.setArrivalTime(LocalDateTime.parse(uploadDisposingResultParam.getArrivalTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); arrivalSituation.setId(uploadDisposingResultParam.getArrivalSituationId()); iArrivalSituationService.updateById(arrivalSituation); //文书 String handType = "02"; ImageResources imageResources = new ImageResources(); imageResources.setType(handType); imageResources.setBelongToId(uploadDisposingResultParam.getCaseId()); imageResources.setUrl(StringUtils.joinWith(",", uploadDisposingResultParam.getPic(), uploadDisposingResultParam.getSituationPic())); imageResources.setId(uploadDisposingResultParam.getImageResourcesId()); iImageResourcesService.updateById(imageResources); if (uploadDisposingResultParam.getWritCode() != null && uploadDisposingResultParam.getWritType() != null) { Writ writ = new Writ(); BeanUtils.copyProperties(uploadDisposingResultParam, writ); writ.setBaseCaseId(uploadDisposingResultParam.getCaseId()); writ.setIllegalBuildingId(uploadDisposingResultParam.getCaseId()); writ.setLimitTime(LocalDateTime.parse(uploadDisposingResultParam.getLimitTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); writ.setRectifyTime(LocalDateTime.parse(uploadDisposingResultParam.getRectifyTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); writ.setSendTime(LocalDateTime.parse(uploadDisposingResultParam.getSendTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); iWritService.updateById(writ); imageResources.setUrl(StringUtils .joinWith(",", uploadDisposingResultParam.getPic() , uploadDisposingResultParam.getSituationPic() , uploadDisposingResultParam.getOriginalPic() , uploadDisposingResultParam.getOtherPic() , uploadDisposingResultParam.getRectifiedPic() , uploadDisposingResultParam.getWritPic())); iImageResourcesService.updateById(imageResources); } baseCaseService.update(new LambdaUpdateWrapper().eq(BaseCase::getId, uploadDisposingResultParam.getCaseId()).set(BaseCase::getState, BaseCaseStatus.DISPOSE)); } else { //当事人 PartyInfo partyInfo = new PartyInfo(); BeanUtils.copyProperties(uploadDisposingResultParam, partyInfo); partyInfo.setCreateUser(user.getUserId().intValue()); partyInfo.setCreateTime(LocalDateTime.now()); iPartyInfoService.save(partyInfo); //调查取证 Investigation investigation = new Investigation(); BeanUtils.copyProperties(uploadDisposingResultParam, investigation); investigation.setBaseCaseId(uploadDisposingResultParam.getCaseId()); investigation.setCreateTime(LocalDateTime.now()); investigation.setCreateUser(user.getUserId()); investigation.setPartyId(partyInfo.getId()); investigation.setInvestigationTime(LocalDateTime.parse(uploadDisposingResultParam.getInvestigationTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); iInvestigationService.save(investigation); //到达 ArrivalSituation arrivalSituation = new ArrivalSituation(); BeanUtils.copyProperties(uploadDisposingResultParam, arrivalSituation); arrivalSituation.setBaseCaseId(uploadDisposingResultParam.getCaseId()); arrivalSituation.setCreateTime(LocalDateTime.now()); arrivalSituation.setCreateUser(user.getUserId()); arrivalSituation.setArrivalTime(LocalDateTime.parse(uploadDisposingResultParam.getArrivalTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); iArrivalSituationService.save(arrivalSituation); //文书 String handType = "02"; ImageResources imageResources = new ImageResources(); imageResources.setType(handType); imageResources.setBelongToId(uploadDisposingResultParam.getCaseId()); imageResources.setCreateTime(LocalDateTime.now()); imageResources.setCreateUser(user.getUserId()); imageResources.setUrl(StringUtils.joinWith(",", uploadDisposingResultParam.getPic(), uploadDisposingResultParam.getSituationPic())); iImageResourcesService.save(imageResources); if (uploadDisposingResultParam.getWritCode() != null && uploadDisposingResultParam.getWritType() != null) { Writ writ = new Writ(); BeanUtils.copyProperties(uploadDisposingResultParam, writ); writ.setBaseCaseId(uploadDisposingResultParam.getCaseId()); writ.setIllegalBuildingId(uploadDisposingResultParam.getCaseId()); writ.setCreateTime(LocalDateTime.now()); writ.setCreateUser(user.getUserId()); writ.setLimitTime(LocalDateTime.parse(uploadDisposingResultParam.getLimitTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); writ.setRectifyTime(LocalDateTime.parse(uploadDisposingResultParam.getRectifyTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); writ.setSendTime(LocalDateTime.parse(uploadDisposingResultParam.getSendTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); iWritService.save(writ); imageResources.setUrl(StringUtils .joinWith(",", uploadDisposingResultParam.getPic() , uploadDisposingResultParam.getSituationPic() , uploadDisposingResultParam.getOriginalPic() , uploadDisposingResultParam.getOtherPic() , uploadDisposingResultParam.getRectifiedPic() , uploadDisposingResultParam.getWritPic())); iImageResourcesService.updateById(imageResources); } baseCaseService.update(new LambdaUpdateWrapper().eq(BaseCase::getId, uploadDisposingResultParam.getCaseId()).set(BaseCase::getState, BaseCaseStatus.DISPOSE)); } String stepName = StepName.CHECK.getName(); DisposeRecord disposeRecord = new DisposeRecord(); disposeRecord.setBaseCaseId(uploadDisposingResultParam.getCaseId()); disposeRecord.setState(0); disposeRecord.setCreateTime(LocalDateTime.now()); disposeRecord.setCreateUser(user.getUserId()); disposeRecord.setStepName(stepName); disposeRecord.setStartTime(LocalDateTime.now()); //结束上传处置流程 QueryWrapper qureyDispatch = new QueryWrapper<>(); qureyDispatch.eq("name", StepName.DISPOSE.getName()); WorkflowConfigStep dispatchStep = workflowConfigStepMapper.selectOne(qureyDispatch); UpdateWrapper updateWrapper = new UpdateWrapper<>(); updateWrapper.eq("base_case_id", disposeRecord.getBaseCaseId()).eq("workflow_config_step_id", dispatchStep.getId()); DisposeRecord updateRecord = new DisposeRecord(); updateRecord.setState(1); updateRecord.setEndTime(LocalDateTime.now()); updateRecord.setHandlerId(disposeRecord.getCreateUser()); updateRecord.setResult(uploadDisposingResultParam.getDescription()); baseMapper.update(updateRecord, updateWrapper); QueryWrapper stepQurey = new QueryWrapper<>(); stepQurey.eq("name", disposeRecord.getStepName()); WorkflowConfigStep workflowConfigStep = workflowConfigStepMapper.selectOne(stepQurey); if (workflowConfigStep == null) { throw new ApiException("未查询到该流程环节"); } //设置流程环节数据 disposeRecord.setWorkflowConfigStepId(workflowConfigStep.getId()); disposeRecord.setHandlerRoleId(workflowConfigStep.getRoleId()); return baseMapper.insert(disposeRecord) == 1 ? true : false; } }