| | |
| | | package com.ycl.service.caseHandler.impl; |
| | | |
| | | import cn.hutool.core.util.PageUtil; |
| | | import com.alibaba.druid.sql.PagerUtils; |
| | | 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.api.CommonResult; |
| | | 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.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 lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @since 2022-09-24 |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | public class DisposeRecordServiceImpl extends ServiceImpl<DisposeRecordMapper, DisposeRecord> implements IDisposeRecordService { |
| | | |
| | | @Resource |
| | | BaseCaseMapper baseCaseMapper; |
| | | |
| | | @Resource |
| | | DisposeRecordMapper disposeRecordMapper; |
| | | @Resource |
| | | WorkflowConfigStepMapper workflowConfigStepMapper; |
| | | |
| | | @Autowired |
| | | IInvestigationService iInvestigationService; |
| | | @Autowired |
| | |
| | | IDisposeRecordService iDisposeRecordService; |
| | | @Autowired |
| | | IImageResourcesService iImageResourcesService; |
| | | public final static Short LAST_WEEK = 0; |
| | | public final static Short LAST_MONTH = 1; |
| | | public final static Short LAST_THREEMONTH = 2; |
| | | |
| | | @Override |
| | | public List<MyBacklogVO> listMyTask(String num, Long userId) { |
| | | return disposeRecordMapper.selectMyBackList(userId, num); |
| | | public Page<MyBacklogVO> listMyTask(String num, Long userId, Short type, Short source, Short time, Integer current, Integer pageSize) { |
| | | LocalDateTime alarmTimeStart = null; |
| | | LocalDateTime alarmTimeEnd = null; |
| | | if (Objects.equals(time, LAST_WEEK)) { |
| | | alarmTimeStart = LocalDateTime.now().minusDays(7); |
| | | alarmTimeEnd = LocalDateTime.now(); |
| | | } else if (Objects.equals(time, LAST_MONTH)) { |
| | | alarmTimeStart = LocalDateTime.now().minusMonths(1); |
| | | alarmTimeEnd = LocalDateTime.now(); |
| | | } else if (Objects.equals(time, LAST_THREEMONTH)) { |
| | | alarmTimeStart = LocalDateTime.now().minusMonths(3); |
| | | alarmTimeEnd = LocalDateTime.now(); |
| | | } |
| | | Integer pageIndex = PageUtil.getStart(current - 1, pageSize); |
| | | List<MyBacklogVO> list = disposeRecordMapper.selectMyBackList(userId, num, alarmTimeStart, alarmTimeEnd, source, type, pageIndex, pageSize); |
| | | Long total = disposeRecordMapper.selectMyBackListTotal(userId, num, alarmTimeStart, alarmTimeEnd, source, type); |
| | | |
| | | list.forEach(o -> { |
| | | if (o.getPictureList() != null && o.getPictureList().size() > 0) { |
| | | o.setPicture(o.getPictureList().get(0).getUrl()); |
| | | } |
| | | }); |
| | | Page<MyBacklogVO> page = new Page<>(); |
| | | page.setRecords(list); |
| | | page.setTotal(total); |
| | | return page; |
| | | } |
| | | |
| | | @Override |
| | | public Long listMyTaskCount(String num, Long userId, Short type, Short source, Short time) { |
| | | LocalDateTime alarmTimeStart = null; |
| | | LocalDateTime alarmTimeEnd = null; |
| | | if (Objects.equals(time, LAST_WEEK)) { |
| | | alarmTimeStart = LocalDateTime.now().minusDays(7); |
| | | alarmTimeEnd = LocalDateTime.now(); |
| | | } else if (Objects.equals(time, LAST_MONTH)) { |
| | | alarmTimeStart = LocalDateTime.now().minusMonths(1); |
| | | alarmTimeEnd = LocalDateTime.now(); |
| | | } else if (Objects.equals(time, LAST_THREEMONTH)) { |
| | | alarmTimeStart = LocalDateTime.now().minusMonths(3); |
| | | alarmTimeEnd = LocalDateTime.now(); |
| | | } |
| | | return disposeRecordMapper.selectMyBackListTotal(userId, num, alarmTimeStart, alarmTimeEnd, source, type); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Boolean saveUpload(Long caseId, Integer type, UploadDisposingResultParam uploadDisposingResultParam) { |
| | | public CommonResult saveOrUpdateUpload(UploadDisposingResultParam uploadDisposingResultParam) { |
| | | log.info("参数------------------>{}", uploadDisposingResultParam); |
| | | if (uploadDisposingResultParam.getArrivalTime() != null) { |
| | | uploadDisposingResultParam.setArrivalTime(uploadDisposingResultParam.getArrivalTime().replace("/", "-")); |
| | | } |
| | | if (uploadDisposingResultParam.getInvestigationTime() != null) { |
| | | uploadDisposingResultParam.setInvestigationTime(uploadDisposingResultParam.getInvestigationTime().replace("/", "-")); |
| | | } |
| | | |
| | | List<String> pics = new ArrayList<>(); |
| | | uploadDisposingResultParam.getPic().forEach(o -> { |
| | | pics.add(o.replace("/sccg/API/img?fileUrl=", "")); |
| | | }); |
| | | uploadDisposingResultParam.setPic(pics); |
| | | |
| | | List<String> situationPics = new ArrayList<>(); |
| | | uploadDisposingResultParam.getSituationPic().forEach(o -> { |
| | | situationPics.add(o.replace("/sccg/API/img?fileUrl=", "")); |
| | | }); |
| | | uploadDisposingResultParam.setSituationPic(situationPics); |
| | | |
| | | AdminUserDetails user = (AdminUserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); |
| | | //当事人 |
| | | PartyInfo partyInfo = new PartyInfo(); |
| | | if (StringUtils.isNotEmpty(uploadDisposingResultParam.getName())) { |
| | | List<ArrivalSituation> list = iArrivalSituationService.list(new LambdaQueryWrapper<ArrivalSituation>().eq(ArrivalSituation::getBaseCaseId, uploadDisposingResultParam.getCaseId())); |
| | | if (!list.isEmpty()) { |
| | | //TODO:违规没有当事人ID,违建才有 |
| | | if (uploadDisposingResultParam.getPartyInfoId() != null) { |
| | | //当事人 |
| | | PartyInfo partyInfo = new PartyInfo(); |
| | | BeanUtils.copyProperties(uploadDisposingResultParam, partyInfo); |
| | | //TODO:前端回显只有当事人姓名需要在详情返回 |
| | | //TODO:后台上报当事人信息填不进去 |
| | | partyInfo.setId(uploadDisposingResultParam.getPartyInfoId()); |
| | | iPartyInfoService.updateById(partyInfo); |
| | | //调查取证 |
| | | Investigation investigation = new Investigation(); |
| | | BeanUtils.copyProperties(uploadDisposingResultParam, investigation); |
| | | investigation.setBaseCaseId(uploadDisposingResultParam.getCaseId()); |
| | | investigation.setPartyId(partyInfo.getId()); |
| | | //TODO:改为集合的字符串形式 |
| | | investigation.setPic(String.join(",", uploadDisposingResultParam.getPic())); |
| | | //TODO:小程序前端页面没有调查时间,暂时不填 |
| | | //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()); |
| | | //TODO:改为集合的字符串形式 |
| | | arrivalSituation.setSituationPic(String.join(",", uploadDisposingResultParam.getSituationPic())); |
| | | iArrivalSituationService.updateById(arrivalSituation); |
| | | //文书 |
| | | String handType = "02"; |
| | | iImageResourcesService.deleteByCaseId(uploadDisposingResultParam.getCaseId(), handType); |
| | | ImageResources imageResources = new ImageResources(); |
| | | imageResources.setType(handType); |
| | | imageResources.setBelongToId(uploadDisposingResultParam.getCaseId()); |
| | | imageResources.setUrl(StringUtils.joinWith(",", |
| | | String.join(",", uploadDisposingResultParam.getPic()), |
| | | String.join(",", 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.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<BaseCase>().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(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())); |
| | | //调查取证 |
| | | Investigation investigation = new Investigation(); |
| | | BeanUtils.copyProperties(uploadDisposingResultParam, investigation); |
| | | investigation.setBaseCaseId(uploadDisposingResultParam.getCaseId()); |
| | | investigation.setCreateTime(LocalDateTime.now()); |
| | | //TODO:改为集合的字符串形式 |
| | | investigation.setPic(String.join(",", uploadDisposingResultParam.getPic())); |
| | | investigation.setCreateUser(user.getUserId()); |
| | | investigation.setPartyId(partyInfo.getId()); |
| | | |
| | | //TODO:前端页面没有调查时间,暂时不填 |
| | | // 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()); |
| | | //TODO:改为集合的字符串形式 |
| | | arrivalSituation.setSituationPic(String.join(",", uploadDisposingResultParam.getSituationPic())); |
| | | 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(",", |
| | | String.join(",", uploadDisposingResultParam.getPic()), |
| | | String.join(",", 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("," |
| | | , String.join(",", uploadDisposingResultParam.getPic()) |
| | | , String.join(",", uploadDisposingResultParam.getSituationPic()) |
| | | , uploadDisposingResultParam.getOriginalPic() |
| | | , uploadDisposingResultParam.getOtherPic() |
| | | , uploadDisposingResultParam.getRectifiedPic() |
| | | , uploadDisposingResultParam.getWritPic())); |
| | | iImageResourcesService.updateById(imageResources); |
| | | } |
| | | |
| | | baseCaseService.update(new LambdaUpdateWrapper<BaseCase>().eq(BaseCase::getId, uploadDisposingResultParam.getCaseId()).set(BaseCase::getState, BaseCaseStatus.DISPOSE)); |
| | | } |
| | | 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<BaseCase>().eq(BaseCase::getId, caseId).set(BaseCase::getState, BaseCaseStatus.DISPOSE)); |
| | | String stepName = StepName.CHECK.getName(); |
| | | DisposeRecord disposeRecord = new DisposeRecord(); |
| | | disposeRecord.setBaseCaseId(caseId); |
| | | disposeRecord.setBaseCaseId(uploadDisposingResultParam.getCaseId()); |
| | | disposeRecord.setState(0); |
| | | disposeRecord.setCreateTime(LocalDateTime.now()); |
| | | disposeRecord.setCreateUser(user.getUserId()); |
| | | disposeRecord.setStepName(stepName); |
| | | disposeRecord.setStartTime(LocalDateTime.now()); |
| | | |
| | | //结束上传处置流程 |
| | | QueryWrapper<WorkflowConfigStep> qureyDispatch = new QueryWrapper<>(); |
| | | qureyDispatch.eq("name", StepName.DISPOSE.getName()); |
| | |
| | | //设置流程环节数据 |
| | | disposeRecord.setWorkflowConfigStepId(workflowConfigStep.getId()); |
| | | disposeRecord.setHandlerRoleId(workflowConfigStep.getRoleId()); |
| | | return baseMapper.insert(disposeRecord) == 1 ? true : false; |
| | | boolean result = baseMapper.insert(disposeRecord) == 1 ? true : false; |
| | | if (!result) { |
| | | CommonResult.failed("已提交,请勿重复提交"); |
| | | } |
| | | return CommonResult.success("add success"); |
| | | } |
| | | } |