package com.ycl.service.caseHandler.impl; 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.service.impl.ServiceImpl; import com.ycl.bo.AdminUserDetails; import com.ycl.common.constant.BaseCaseStatus; import com.ycl.common.constant.StepName; import com.ycl.dto.dispatch.UploadDisposingResultParam; import com.ycl.entity.caseHandler.*; 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.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.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 List listMyTask(String num, Long userId) { return disposeRecordMapper.selectMyBackList(userId, num); } @Override @Transactional(rollbackFor = Exception.class) public Boolean saveUpload(Long caseId, Integer type, UploadDisposingResultParam uploadDisposingResultParam) { AdminUserDetails user = (AdminUserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); //当事人 PartyInfo partyInfo = new PartyInfo(); if (StringUtils.isNotEmpty(uploadDisposingResultParam.getName())) { 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(caseId); investigation.setCreateTime(LocalDateTime.now()); investigation.setCreateUser(user.getUserId()); investigation.setPartyId(partyInfo.getId()); iInvestigationService.save(investigation); //到达 ArrivalSituation arrivalSituation = new ArrivalSituation(); BeanUtils.copyProperties(uploadDisposingResultParam, arrivalSituation); arrivalSituation.setBaseCaseId(caseId); arrivalSituation.setCreateTime(LocalDateTime.now()); arrivalSituation.setCreateUser(user.getUserId()); iArrivalSituationService.save(arrivalSituation); //文书 Integer illegalBuildingType = 2; Integer violation = 1; String handType = "02"; ImageResources imageResources = new ImageResources(); imageResources.setType(handType); imageResources.setBelongToId(caseId); imageResources.setCreateTime(LocalDateTime.now()); imageResources.setCreateUser(user.getUserId()); if (type == violation) { imageResources.setUrl(StringUtils.joinWith(",", uploadDisposingResultParam.getPic(), uploadDisposingResultParam.getSituationPic())); iImageResourcesService.save(imageResources); } if (type == illegalBuildingType) { Writ writ = new Writ(); BeanUtils.copyProperties(uploadDisposingResultParam, writ); writ.setBaseCaseId(caseId); writ.setIllegalBuildingId(caseId); writ.setCreateTime(LocalDateTime.now()); writ.setCreateUser(user.getUserId()); iWritService.save(writ); imageResources.setUrl(StringUtils .joinWith(",", uploadDisposingResultParam.getPic() , uploadDisposingResultParam.getSituationPic() , uploadDisposingResultParam.getOriginalPic() , uploadDisposingResultParam.getOtherPic() , uploadDisposingResultParam.getRectifiedPic() , uploadDisposingResultParam.getWritPic())); iImageResourcesService.save(imageResources); } baseCaseService.update(new LambdaUpdateWrapper().eq(BaseCase::getId, caseId).set(BaseCase::getState, BaseCaseStatus.DISPOSE)); String stepName = StepName.CHECK.getName(); DisposeRecord disposeRecord = new DisposeRecord(); disposeRecord.setBaseCaseId(caseId); 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; } }