|  |  |  | @ -1,10 +1,13 @@ | 
			
		
	
		
			
				
					|  |  |  |  | package com.hnac.hzims.operational.duty.service.impl; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | import com.alibaba.fastjson.JSON; | 
			
		
	
		
			
				
					|  |  |  |  | import com.alibaba.fastjson.JSONObject; | 
			
		
	
		
			
				
					|  |  |  |  | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 
			
		
	
		
			
				
					|  |  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
			
		
	
		
			
				
					|  |  |  |  | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; | 
			
		
	
		
			
				
					|  |  |  |  | import com.baomidou.mybatisplus.core.metadata.IPage; | 
			
		
	
		
			
				
					|  |  |  |  | import com.baomidou.mybatisplus.core.toolkit.Wrappers; | 
			
		
	
		
			
				
					|  |  |  |  | import com.google.common.collect.Lists; | 
			
		
	
		
			
				
					|  |  |  |  | import com.hnac.hzims.message.MessageConstants; | 
			
		
	
		
			
				
					|  |  |  |  | import com.hnac.hzims.message.dto.MessagePushRecordDto; | 
			
		
	
		
			
				
					|  |  |  |  | import com.hnac.hzims.message.fegin.IMessageClient; | 
			
		
	
	
		
			
				
					|  |  |  | @ -17,6 +20,7 @@ import com.hnac.hzims.operational.duty.constant.DutyProcessConstant; | 
			
		
	
		
			
				
					|  |  |  |  | import com.hnac.hzims.operational.duty.constant.DutyRecProcessConstant; | 
			
		
	
		
			
				
					|  |  |  |  | import com.hnac.hzims.operational.duty.dto.ChangeShiftsReqDTO; | 
			
		
	
		
			
				
					|  |  |  |  | import com.hnac.hzims.operational.duty.dto.ChangeShiftsRspDTO; | 
			
		
	
		
			
				
					|  |  |  |  | import com.hnac.hzims.operational.duty.dto.ImsDutyRecDTO; | 
			
		
	
		
			
				
					|  |  |  |  | import com.hnac.hzims.operational.duty.entity.*; | 
			
		
	
		
			
				
					|  |  |  |  | import com.hnac.hzims.operational.duty.enume.DutyMainStatus; | 
			
		
	
		
			
				
					|  |  |  |  | import com.hnac.hzims.operational.duty.enume.DutyRecStatus; | 
			
		
	
	
		
			
				
					|  |  |  | @ -30,6 +34,7 @@ import com.hnac.hzims.operational.duty.vo.ImsRecVo; | 
			
		
	
		
			
				
					|  |  |  |  | import com.hnac.hzims.operational.duty.vo.ImsSchedulingVo; | 
			
		
	
		
			
				
					|  |  |  |  | import com.hnac.hzims.operational.duty.wrapper.ImsDutyRecWrapper; | 
			
		
	
		
			
				
					|  |  |  |  | import com.hnac.hzims.operational.station.service.IStationService; | 
			
		
	
		
			
				
					|  |  |  |  | import com.hnac.hzinfo.inspect.plan.PlanContants; | 
			
		
	
		
			
				
					|  |  |  |  | import com.hnac.hzinfo.inspect.plan.feign.IInspectPlanClient; | 
			
		
	
		
			
				
					|  |  |  |  | import com.hnac.hzinfo.inspect.plan.vo.PlanVO; | 
			
		
	
		
			
				
					|  |  |  |  | import lombok.extern.slf4j.Slf4j; | 
			
		
	
	
		
			
				
					|  |  |  | @ -49,13 +54,16 @@ import org.springblade.system.user.feign.IUserClient; | 
			
		
	
		
			
				
					|  |  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
			
		
	
		
			
				
					|  |  |  |  | import org.springframework.stereotype.Service; | 
			
		
	
		
			
				
					|  |  |  |  | import org.springframework.transaction.annotation.Transactional; | 
			
		
	
		
			
				
					|  |  |  |  | import org.springframework.util.Assert; | 
			
		
	
		
			
				
					|  |  |  |  | import org.springframework.util.ObjectUtils; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | import java.math.BigDecimal; | 
			
		
	
		
			
				
					|  |  |  |  | import java.sql.Time; | 
			
		
	
		
			
				
					|  |  |  |  | import java.text.SimpleDateFormat; | 
			
		
	
		
			
				
					|  |  |  |  | import java.time.LocalDate; | 
			
		
	
		
			
				
					|  |  |  |  | import java.time.*; | 
			
		
	
		
			
				
					|  |  |  |  | import java.time.format.DateTimeFormatter; | 
			
		
	
		
			
				
					|  |  |  |  | import java.util.*; | 
			
		
	
		
			
				
					|  |  |  |  | import java.util.function.Function; | 
			
		
	
		
			
				
					|  |  |  |  | import java.util.stream.Collectors; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  |  | @ -187,6 +195,104 @@ public class ImsDutyRecServiceImpl extends BaseServiceImpl<ImsDutyRecMapper, Ims | 
			
		
	
		
			
				
					|  |  |  |  |         return R.status(true); | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |  |      * 开启交接班 | 
			
		
	
		
			
				
					|  |  |  |  |      * @param recDTO 交接班信息 - 巡检路线ID、NAME、DATA | 
			
		
	
		
			
				
					|  |  |  |  |      * @return 交接班成功标识 | 
			
		
	
		
			
				
					|  |  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |  |     @Override | 
			
		
	
		
			
				
					|  |  |  |  |     public Boolean changeShift(ImsDutyRecDTO recDTO) { | 
			
		
	
		
			
				
					|  |  |  |  |         // 获取班组组长
 | 
			
		
	
		
			
				
					|  |  |  |  |         Long managerId = this.getHandleGroupManagerByDuty(recDTO.getDutyId()); | 
			
		
	
		
			
				
					|  |  |  |  |         Assert.isTrue(Func.isNotEmpty(managerId),() -> { | 
			
		
	
		
			
				
					|  |  |  |  |             throw new ServiceException("获取值班班组长失败!"); | 
			
		
	
		
			
				
					|  |  |  |  |         }); | 
			
		
	
		
			
				
					|  |  |  |  |         // 新建巡检计划并获取巡检任务Id
 | 
			
		
	
		
			
				
					|  |  |  |  |         PlanVO planVO = new PlanVO(); | 
			
		
	
		
			
				
					|  |  |  |  |         planVO.setRouteId(recDTO.getRouteId()); | 
			
		
	
		
			
				
					|  |  |  |  |         planVO.setRouteData(recDTO.getRouteData()); | 
			
		
	
		
			
				
					|  |  |  |  |         planVO.setRouteName(recDTO.getRouteName()); | 
			
		
	
		
			
				
					|  |  |  |  |         planVO.setPlanUsers(Lists.newArrayList(managerId)); | 
			
		
	
		
			
				
					|  |  |  |  |         Long inspectTaskId = this.createInspectPlan(planVO); | 
			
		
	
		
			
				
					|  |  |  |  |         ImsDutyRecEntity recEntity = BeanUtil.copy(recDTO,ImsDutyRecEntity.class); | 
			
		
	
		
			
				
					|  |  |  |  |         recEntity.setInspectTaskId(inspectTaskId); | 
			
		
	
		
			
				
					|  |  |  |  |         // 返回流程id写入业务表
 | 
			
		
	
		
			
				
					|  |  |  |  |         recDTO.setExecTime(new Date()); | 
			
		
	
		
			
				
					|  |  |  |  |         recDTO.setStatus(DutyRecStatus.EXEC.getVal()); | 
			
		
	
		
			
				
					|  |  |  |  |         // 开启值班交接班流程
 | 
			
		
	
		
			
				
					|  |  |  |  |         BladeFlow bladeFlow = this.startDutyRecProcess(recEntity, managerId); | 
			
		
	
		
			
				
					|  |  |  |  |         recDTO.setProcessInstanceId(bladeFlow.getProcessInstanceId()); | 
			
		
	
		
			
				
					|  |  |  |  |         return updateById(recEntity); | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |  |      * 根据值班ID获取值班负责人Id | 
			
		
	
		
			
				
					|  |  |  |  |      * @param dutyId 值班ID | 
			
		
	
		
			
				
					|  |  |  |  |      * @return 值班负责人ID | 
			
		
	
		
			
				
					|  |  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |  |     private Long getHandleGroupManagerByDuty(Long dutyId) { | 
			
		
	
		
			
				
					|  |  |  |  |         ImsDutyMainEntity dutyMain = imsDutyMainMapper.selectById(dutyId); | 
			
		
	
		
			
				
					|  |  |  |  |         // 判断是否已交班
 | 
			
		
	
		
			
				
					|  |  |  |  |         List<ImsDutyRecEntity> dutyRecs = this.list(Wrappers.<ImsDutyRecEntity>lambdaQuery().eq(ImsDutyRecEntity::getDutyId, dutyId)); | 
			
		
	
		
			
				
					|  |  |  |  |         Assert.isTrue(CollectionUtil.isNotEmpty(dutyRecs),() -> { | 
			
		
	
		
			
				
					|  |  |  |  |             throw new ServiceException("您已交班,请勿重复交班!"); | 
			
		
	
		
			
				
					|  |  |  |  |         }); | 
			
		
	
		
			
				
					|  |  |  |  |         //根据上一班值班id查询值班信息
 | 
			
		
	
		
			
				
					|  |  |  |  |         ImsDutyMainEntity preDutyMain = imsDutyMainMapper.selectOne(Wrappers.<ImsDutyMainEntity>lambdaQuery().eq(ImsDutyMainEntity::getPreDutyId, dutyId)); | 
			
		
	
		
			
				
					|  |  |  |  |         Assert.isTrue(ObjectUtil.isEmpty(preDutyMain),() -> { | 
			
		
	
		
			
				
					|  |  |  |  |             throw new ServiceException("当前时间没有接班人!"); | 
			
		
	
		
			
				
					|  |  |  |  |         }); | 
			
		
	
		
			
				
					|  |  |  |  |         //获取接班人班组组长
 | 
			
		
	
		
			
				
					|  |  |  |  |         Long managerId; | 
			
		
	
		
			
				
					|  |  |  |  |         if (Func.isNotEmpty(dutyMain.getDutyGroupId())) { | 
			
		
	
		
			
				
					|  |  |  |  |             ImsDutyGroupEntity groupEntity = imsDutyGroupService.getById(dutyMain.getDutyGroupId()); | 
			
		
	
		
			
				
					|  |  |  |  |             ImsDutyGroupPEntity groupPEntity = imsDutyGroupPService.getOne(new LambdaQueryWrapper<ImsDutyGroupPEntity>() {{ | 
			
		
	
		
			
				
					|  |  |  |  |                 eq(ImsDutyGroupPEntity::getGroupId, groupEntity.getId()); | 
			
		
	
		
			
				
					|  |  |  |  |                 eq(ImsDutyGroupPEntity::getPersonId, groupEntity.getManagerId()).last(" LIMIT 1"); | 
			
		
	
		
			
				
					|  |  |  |  |             }}); | 
			
		
	
		
			
				
					|  |  |  |  |             Assert.isTrue(ObjectUtil.isEmpty(groupPEntity), () -> { | 
			
		
	
		
			
				
					|  |  |  |  |                 throw new ServiceException("接班班组长不存在,请指定班组长后进行交班!"); | 
			
		
	
		
			
				
					|  |  |  |  |             }); | 
			
		
	
		
			
				
					|  |  |  |  |             managerId = groupEntity.getManagerId(); | 
			
		
	
		
			
				
					|  |  |  |  |         } else { | 
			
		
	
		
			
				
					|  |  |  |  |             managerId = Optional.ofNullable(imsDutyMainPersonService.selectByMainId(dutyMain.getId())).filter(CollectionUtil::isNotEmpty) | 
			
		
	
		
			
				
					|  |  |  |  |                     .map(list -> list.get(0)).map(ImsDutyMainPersonEntity::getDutyChargePerson).orElse(null); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         R<User> manager = userClient.userInfoById(managerId); | 
			
		
	
		
			
				
					|  |  |  |  |         Assert.isTrue(manager.isSuccess() && ObjectUtil.isNotEmpty(manager.getData()),() -> { | 
			
		
	
		
			
				
					|  |  |  |  |             throw new ServiceException("获取接班组长失败,值班组长ID为:" + Optional.ofNullable(managerId).map(String::valueOf).orElse("")); | 
			
		
	
		
			
				
					|  |  |  |  |         }); | 
			
		
	
		
			
				
					|  |  |  |  |         return managerId; | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |  |      * 开启值班交接班流程 | 
			
		
	
		
			
				
					|  |  |  |  |      * @param recEntity 交接班信息 | 
			
		
	
		
			
				
					|  |  |  |  |      * @return 工作流执行结果 | 
			
		
	
		
			
				
					|  |  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |  |     private BladeFlow startDutyRecProcess(ImsDutyRecEntity recEntity ,Long managerId) { | 
			
		
	
		
			
				
					|  |  |  |  |         ImsDutyRecDTO recDTO = BeanUtil.copy(recEntity,ImsDutyRecDTO.class); | 
			
		
	
		
			
				
					|  |  |  |  |         ImsSchedulingVo currentDuty = imsDutyMainService.getByIdOneV2(recDTO.getId()); | 
			
		
	
		
			
				
					|  |  |  |  |         recDTO.setHeadDutyMainVo(currentDuty); | 
			
		
	
		
			
				
					|  |  |  |  |         List<ImsDutyMainEntity> carryDuties = imsDutyMainService.list(Wrappers.<ImsDutyMainEntity>lambdaQuery().eq(ImsDutyMainEntity::getPreDutyId, recDTO.getId())); | 
			
		
	
		
			
				
					|  |  |  |  |         Assert.isTrue(carryDuties.size() <= 1,() -> { | 
			
		
	
		
			
				
					|  |  |  |  |             throw new ServiceException("交班失败,接班不唯一,接班数量为:" + carryDuties.size()); | 
			
		
	
		
			
				
					|  |  |  |  |         }); | 
			
		
	
		
			
				
					|  |  |  |  |         recDTO.setCarryDutyMainVo(imsDutyMainService.getByIdOneV2(carryDuties.get(0).getId())); | 
			
		
	
		
			
				
					|  |  |  |  |         Map<String,Object> variable = BeanUtil.toMap(recDTO); | 
			
		
	
		
			
				
					|  |  |  |  |         variable.put("taskId", recEntity.getId()); | 
			
		
	
		
			
				
					|  |  |  |  |         variable.put(DutyRecProcessConstant.TASK_VARIABLE_CARRY_USER, TaskUtil.getTaskUser(managerId.toString())); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         R<BladeFlow> flowResult = flowClient.startProcessInstanceByKey( | 
			
		
	
		
			
				
					|  |  |  |  |                 DutyRecProcessConstant.DUTY_REC_FLOW_KEY, | 
			
		
	
		
			
				
					|  |  |  |  |                 StringUtil.format("{}:{}", DutyRecProcessConstant.DUTY_REC_PROCESS_TABLE, recEntity.getId()), | 
			
		
	
		
			
				
					|  |  |  |  |                 variable | 
			
		
	
		
			
				
					|  |  |  |  |         ); | 
			
		
	
		
			
				
					|  |  |  |  |         Assert.isTrue(flowResult.isSuccess(),() -> { | 
			
		
	
		
			
				
					|  |  |  |  |             throw new ServiceException(flowResult.getMsg()); | 
			
		
	
		
			
				
					|  |  |  |  |         }); | 
			
		
	
		
			
				
					|  |  |  |  |         return flowResult.getData(); | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     private void updateMain(Long dutyId) { | 
			
		
	
		
			
				
					|  |  |  |  |         ImsDutyMainEntity imsDutyMainEntity = new ImsDutyMainEntity(); | 
			
		
	
	
		
			
				
					|  |  |  | @ -1114,41 +1220,46 @@ public class ImsDutyRecServiceImpl extends BaseServiceImpl<ImsDutyRecMapper, Ims | 
			
		
	
		
			
				
					|  |  |  |  |         log.info(booleanR.toString()); | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     //新增巡检计划   获取巡检任务ID
 | 
			
		
	
		
			
				
					|  |  |  |  |     public Long getInspectTaskId(PlanVO vo, Long princId) { | 
			
		
	
		
			
				
					|  |  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |  |      * 创建交接班巡检任务 | 
			
		
	
		
			
				
					|  |  |  |  |      * @param vo 巡检任务VO对象 | 
			
		
	
		
			
				
					|  |  |  |  |      * @return 巡检任务ID | 
			
		
	
		
			
				
					|  |  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |  |     private Long createInspectPlan(PlanVO vo) { | 
			
		
	
		
			
				
					|  |  |  |  |         // 填充巡检计划信息
 | 
			
		
	
		
			
				
					|  |  |  |  |         vo.setName(DateUtil.format(new Date(), "yyyy-MM-dd HH") + "-交接班巡视"); | 
			
		
	
		
			
				
					|  |  |  |  |         vo.setMethod(DutyRecProcessConstant.INSPECT_PANL_METHOD); | 
			
		
	
		
			
				
					|  |  |  |  |         vo.setAutoVideo(DutyRecProcessConstant.INSPECT_PANL_AUTO_VIDEO); | 
			
		
	
		
			
				
					|  |  |  |  |         vo.setCycle(DutyRecProcessConstant.INSPECT_PANL_AUTO_CYCLE); | 
			
		
	
		
			
				
					|  |  |  |  |         Date date = new Date(); | 
			
		
	
		
			
				
					|  |  |  |  |         Date startDate = minutlDate(date, 5); | 
			
		
	
		
			
				
					|  |  |  |  |         Date endDate = hrDate(date, 2); | 
			
		
	
		
			
				
					|  |  |  |  |         LocalDate startTime = LocalDate.parse(DateUtil.format(startDate, DateUtil.PATTERN_DATE), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); | 
			
		
	
		
			
				
					|  |  |  |  |         LocalDate endTime = LocalDate.parse(DateUtil.format(endDate, DateUtil.PATTERN_DATE), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); | 
			
		
	
		
			
				
					|  |  |  |  |         vo.setStartTime(startTime); | 
			
		
	
		
			
				
					|  |  |  |  |         vo.setEndTime(endTime); | 
			
		
	
		
			
				
					|  |  |  |  |         vo.setType(DutyRecProcessConstant.INSPECT_PANL_TYPE); | 
			
		
	
		
			
				
					|  |  |  |  |         vo.setMethod(PlanContants.PlanMethodEnum.SEIZE.getMethod()); | 
			
		
	
		
			
				
					|  |  |  |  |         vo.setAutoVideo(PlanContants.AutoVideoEnum.NO.getFlag()); | 
			
		
	
		
			
				
					|  |  |  |  |         vo.setCycle(PlanContants.PlanCycleEnum.NEVER_CYCLE.getCycle()); | 
			
		
	
		
			
				
					|  |  |  |  |         vo.setType(PlanContants.PlanTypeEnum.USER_TYPE.getType()); | 
			
		
	
		
			
				
					|  |  |  |  |         vo.setTaskTimesADay(DutyRecProcessConstant.INSPECT_PANL_TASK_TIMES_A_DAY); | 
			
		
	
		
			
				
					|  |  |  |  |         vo.setPlanType(PlanContants.PlanContentTypeEnum.COMMON.getDesc()); | 
			
		
	
		
			
				
					|  |  |  |  |         vo.setStartRemind(DutyRecProcessConstant.INSPECT_PANL_START_REMIND); | 
			
		
	
		
			
				
					|  |  |  |  |         vo.setEndRemind(DutyRecProcessConstant.INSPECT_PANL_END_REMIND); | 
			
		
	
		
			
				
					|  |  |  |  |         String execStartTime = DateUtil.format(startDate, DateUtil.PATTERN_TIME); | 
			
		
	
		
			
				
					|  |  |  |  |         String execEndTime = DateUtil.format(endDate, DateUtil.PATTERN_TIME); | 
			
		
	
		
			
				
					|  |  |  |  |         List<Map<String, Object>> listMap = new ArrayList<>(); | 
			
		
	
		
			
				
					|  |  |  |  |         Map<String, Object> map = new HashMap<>(); | 
			
		
	
		
			
				
					|  |  |  |  |         map.put("execStartTime", execStartTime); | 
			
		
	
		
			
				
					|  |  |  |  |         map.put("execEndTime", execEndTime); | 
			
		
	
		
			
				
					|  |  |  |  |         listMap.add(map); | 
			
		
	
		
			
				
					|  |  |  |  |         vo.setExecTimeJson(JSONObject.toJSONString(listMap)); | 
			
		
	
		
			
				
					|  |  |  |  |         List<Long> list = new ArrayList<>(); | 
			
		
	
		
			
				
					|  |  |  |  |         list.add(princId); | 
			
		
	
		
			
				
					|  |  |  |  |         vo.setPlanType("common"); | 
			
		
	
		
			
				
					|  |  |  |  |         vo.setPlanUsers(list); | 
			
		
	
		
			
				
					|  |  |  |  |         R<List<Long>> listR = inspectPlanClient.addPlanAndChecked(vo); | 
			
		
	
		
			
				
					|  |  |  |  |         List<Long> data = listR.getData(); | 
			
		
	
		
			
				
					|  |  |  |  |         if (CollectionUtil.isNotEmpty(data)) { | 
			
		
	
		
			
				
					|  |  |  |  |             return data.get(0); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         return null; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         // 设置巡检计划计划开始结束时间
 | 
			
		
	
		
			
				
					|  |  |  |  |         LocalDateTime now = LocalDateTime.now(); | 
			
		
	
		
			
				
					|  |  |  |  |         LocalDateTime startTime = now.minusMinutes(5); | 
			
		
	
		
			
				
					|  |  |  |  |         LocalDateTime endTime = now.plusHours(2); | 
			
		
	
		
			
				
					|  |  |  |  |         vo.setStartTime(startTime.toLocalDate()); | 
			
		
	
		
			
				
					|  |  |  |  |         vo.setEndTime(endTime.toLocalDate()); | 
			
		
	
		
			
				
					|  |  |  |  |         Map<String, Object> execTime = new HashMap(2){{ | 
			
		
	
		
			
				
					|  |  |  |  |             put("execStartTime",startTime.toLocalTime()); | 
			
		
	
		
			
				
					|  |  |  |  |             put("execEndTime", startTime.toLocalTime()); | 
			
		
	
		
			
				
					|  |  |  |  |         }}; | 
			
		
	
		
			
				
					|  |  |  |  |         List<Map<String, Object>> execTimeList = Lists.newArrayList(execTime); | 
			
		
	
		
			
				
					|  |  |  |  |         vo.setExecTimeJson(JSONObject.toJSONString(execTimeList)); | 
			
		
	
		
			
				
					|  |  |  |  |         R<List<Long>> createPlanResult = inspectPlanClient.addPlanAndChecked(vo); | 
			
		
	
		
			
				
					|  |  |  |  |         Assert.isTrue(createPlanResult.isSuccess(),() -> { | 
			
		
	
		
			
				
					|  |  |  |  |             throw new ServiceException(createPlanResult.getMsg()); | 
			
		
	
		
			
				
					|  |  |  |  |         }); | 
			
		
	
		
			
				
					|  |  |  |  |         return Optional.ofNullable(createPlanResult.getData()).map(list -> list.get(0)).orElse(null); | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     //新增巡检计划   获取巡检任务ID
 | 
			
		
	
		
			
				
					|  |  |  |  |     public Long getInspectTaskId(PlanVO vo, Long princId) { | 
			
		
	
		
			
				
					|  |  |  |  |         vo.setPlanUsers(Lists.newArrayList(princId)); | 
			
		
	
		
			
				
					|  |  |  |  |         return this.createInspectPlan(vo); | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  |  | @ -1244,5 +1355,83 @@ public class ImsDutyRecServiceImpl extends BaseServiceImpl<ImsDutyRecMapper, Ims | 
			
		
	
		
			
				
					|  |  |  |  |         return response; | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     @Override | 
			
		
	
		
			
				
					|  |  |  |  |     public Boolean dealDutyRecFlow(ImsDutyRecDTO recDTO) { | 
			
		
	
		
			
				
					|  |  |  |  |         ImsDutyMainEntity headDutyMain = BeanUtil.copy(recDTO.getHeadDutyMainVo(), ImsDutyMainEntity.class); | 
			
		
	
		
			
				
					|  |  |  |  |         ImsDutyMainEntity carryDutyMain = BeanUtil.copy(recDTO.getCarryDutyMainVo(), ImsDutyMainEntity.class); | 
			
		
	
		
			
				
					|  |  |  |  |         ImsDutyRecEntity dutyRec = BeanUtil.copy(recDTO, ImsDutyRecEntity.class); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         if("接班确认".equals(recDTO.getDealChain())) { | 
			
		
	
		
			
				
					|  |  |  |  |             // 接班确认-获取交接班延时状态
 | 
			
		
	
		
			
				
					|  |  |  |  |             this.getChangeShiftStatus(carryDutyMain,dutyRec.getDelayStatus(),OperationalConstants.DutyRecTypeEnum.CARRY_REC.getVal()); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         // 更新交班值班
 | 
			
		
	
		
			
				
					|  |  |  |  |         Assert.isTrue(imsDutyMainService.updateById(headDutyMain),() -> { | 
			
		
	
		
			
				
					|  |  |  |  |             throw new RuntimeException("更新交班状态失败,交班执行对象为:"+ JSON.toJSONString(recDTO.getHeadDutyMainVo())); | 
			
		
	
		
			
				
					|  |  |  |  |         }); | 
			
		
	
		
			
				
					|  |  |  |  |         // 更新接班值班
 | 
			
		
	
		
			
				
					|  |  |  |  |         Assert.isTrue(imsDutyMainService.updateById(carryDutyMain),() -> { | 
			
		
	
		
			
				
					|  |  |  |  |             throw new RuntimeException("更新接班状态失败,交班执行对象为:"+ JSON.toJSONString(recDTO.getHeadDutyMainVo())); | 
			
		
	
		
			
				
					|  |  |  |  |         }); | 
			
		
	
		
			
				
					|  |  |  |  |         // 更新交接班
 | 
			
		
	
		
			
				
					|  |  |  |  |         Assert.isTrue(this.updateById(dutyRec),() -> { | 
			
		
	
		
			
				
					|  |  |  |  |             throw new RuntimeException("更新交接班失败,更新对象为:"+ JSON.toJSONString(recDTO.getHeadDutyMainVo())); | 
			
		
	
		
			
				
					|  |  |  |  |         }); | 
			
		
	
		
			
				
					|  |  |  |  |         return true; | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |  |      * 计算交接班状态 | 
			
		
	
		
			
				
					|  |  |  |  |      * @param duty 值班信息 | 
			
		
	
		
			
				
					|  |  |  |  |      * @param type 判断交接班延时类型 - 依据 OperationalConstants.DutyRecTypeEnum 枚举类 | 
			
		
	
		
			
				
					|  |  |  |  |      * @return 延时状态 | 
			
		
	
		
			
				
					|  |  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |  |     private Integer getChangeShiftStatus(ImsDutyMainEntity duty, Integer recDelayStatus, int type) { | 
			
		
	
		
			
				
					|  |  |  |  |         Long duration = this.changeShiftDuration(duty, type); | 
			
		
	
		
			
				
					|  |  |  |  |         if (duration > 30) { | 
			
		
	
		
			
				
					|  |  |  |  |             if (recDelayStatus == DutyContants.DutyRecDelayStatusEnum.HAND_DELAY_STATUS.getStatus()) { | 
			
		
	
		
			
				
					|  |  |  |  |                 // 赋值延时状态 为3  交接班延时
 | 
			
		
	
		
			
				
					|  |  |  |  |                 return DutyContants.DutyRecDelayStatusEnum.REC_DELAY_STATUS.getStatus(); | 
			
		
	
		
			
				
					|  |  |  |  |             } else { | 
			
		
	
		
			
				
					|  |  |  |  |                 // 赋值延时状态 为2  接班延时
 | 
			
		
	
		
			
				
					|  |  |  |  |                 return DutyContants.DutyRecDelayStatusEnum.CARRY_DELAY_STATUS.getStatus(); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         return recDelayStatus; | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |  |      * 交接班时间差 | 
			
		
	
		
			
				
					|  |  |  |  |      * @param duty 值班信息 | 
			
		
	
		
			
				
					|  |  |  |  |      * @param type 判断交接班延时类型 - 依据 OperationalConstants.DutyRecTypeEnum 枚举类 | 
			
		
	
		
			
				
					|  |  |  |  |      * @return 延时时长 | 
			
		
	
		
			
				
					|  |  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |  |     private Long changeShiftDuration(ImsDutyMainEntity duty, int type) { | 
			
		
	
		
			
				
					|  |  |  |  |         LocalDateTime now = LocalDateTime.now(); | 
			
		
	
		
			
				
					|  |  |  |  |         // 获取当前值班班次
 | 
			
		
	
		
			
				
					|  |  |  |  |         ImsDutyClassEntity dutyClass = imsDutyClassService.getById(duty.getId()); | 
			
		
	
		
			
				
					|  |  |  |  |         Assert.isTrue(ObjectUtil.isNotEmpty(dutyClass),()-> { | 
			
		
	
		
			
				
					|  |  |  |  |             throw new RuntimeException("接班获取班次失败!"); | 
			
		
	
		
			
				
					|  |  |  |  |         }); | 
			
		
	
		
			
				
					|  |  |  |  |         Instant dutyDateInstant = duty.getDutyDate().toInstant(); | 
			
		
	
		
			
				
					|  |  |  |  |         ZoneId zoneId = ZoneId.systemDefault(); | 
			
		
	
		
			
				
					|  |  |  |  |         Time startTime = dutyClass.getStartTime(); | 
			
		
	
		
			
				
					|  |  |  |  |         Time endTime = dutyClass.getEndTime(); | 
			
		
	
		
			
				
					|  |  |  |  |         // 拼接开始、结束时间
 | 
			
		
	
		
			
				
					|  |  |  |  |         LocalDateTime startDateTime = LocalDateTime.of(dutyDateInstant.atZone(zoneId).toLocalDate(),LocalTime.of(startTime.getHours(),startTime.getMinutes(),startTime.getSeconds())); | 
			
		
	
		
			
				
					|  |  |  |  |         LocalDateTime endDateTime = LocalDateTime.of(dutyDateInstant.atZone(zoneId).toLocalDate(),LocalTime.of(endTime.getHours(),endTime.getMinutes(),endTime.getSeconds())); | 
			
		
	
		
			
				
					|  |  |  |  |         if(endDateTime.isBefore(startDateTime)) { | 
			
		
	
		
			
				
					|  |  |  |  |             endDateTime = endDateTime.plusDays(1); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         // 交班延时判断
 | 
			
		
	
		
			
				
					|  |  |  |  |         if(type == OperationalConstants.DutyRecTypeEnum.HAND_REC.getVal()) { | 
			
		
	
		
			
				
					|  |  |  |  |             return Duration.between(now,endDateTime).toMinutes(); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         // 接班延时判断
 | 
			
		
	
		
			
				
					|  |  |  |  |         else if(type == OperationalConstants.DutyRecTypeEnum.CARRY_REC.getVal()) { | 
			
		
	
		
			
				
					|  |  |  |  |             return Duration.between(now,startDateTime).toMinutes(); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         return null; | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | } | 
			
		
	
	
		
			
				
					|  |  |  | 
 |