| | |
| | | */ |
| | | package org.sxkj.gd.workorder.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | |
| | | import org.sxkj.gd.workorder.enums.WorkOrderTypeEnum; |
| | | import org.sxkj.gd.workorder.excel.GdPatrolTaskExcel; |
| | | import org.sxkj.gd.workorder.mapper.GdPatrolTaskMapper; |
| | | import org.sxkj.gd.workorder.mapper.GdWorkOrderMapper; |
| | | import org.sxkj.gd.workorder.param.GdPatrolTaskAuditParam; |
| | | import org.sxkj.gd.workorder.param.GdPatrolTaskPageParam; |
| | | import org.sxkj.gd.workorder.param.GdPatrolTaskPendingAcceptanceQueryParam; |
| | | import org.sxkj.gd.workorder.service.IGdManageDeviceService; |
| | | import org.sxkj.gd.workorder.service.IGdPatrolTaskService; |
| | | import org.sxkj.gd.workorder.service.IGdTaskResultService; |
| | | import org.sxkj.gd.workorder.service.IGdWorkOrderFlowService; |
| | | import org.sxkj.gd.workorder.utils.GdPatrolReportWordUtil; |
| | | import org.sxkj.gd.workorder.vo.GdPatrolTaskSimpleVO; |
| | | import org.sxkj.gd.workorder.vo.GdPatrolTaskVO; |
| | | import org.sxkj.gd.xingtu.JianXingtuApiService; |
| | | import org.sxkj.resource.entity.Attach; |
| | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 巡查任务表 服务实现类 |
| | |
| | | private JianXingtuApiService jianXingtuApiService; |
| | | @Autowired |
| | | private IGdManageDeviceService gdManageDeviceService; |
| | | @Autowired |
| | | private GdWorkOrderMapper gdWorkOrderMapper; |
| | | |
| | | @Override |
| | | public IPage<GdPatrolTaskVO> selectGdPatrolTaskPage(IPage<GdPatrolTaskVO> page, GdPatrolTaskPageParam gdPatrolTask) { |
| | | List<Long> deptList = new ArrayList<>(); |
| | | if (!AuthUtil.isAdministrator()) { |
| | | deptList = SysCache.getDeptChildIds(Long.valueOf(AuthUtil.getDeptId())); |
| | | if (!(AuthUtil.isAdministrator() || AuthUtil.isAdmin())) { |
| | | deptList = SysCache.getDeptChildIds(Long.valueOf(StringUtil.isBlank(AuthUtil.getDeptId()) ? "0" : AuthUtil.getDeptId())); |
| | | } |
| | | gdPatrolTask.setDeptList(deptList); |
| | | List<GdPatrolTaskVO> gdPatrolTaskVOS = baseMapper.selectGdPatrolTaskPage(page, gdPatrolTask); |
| | | return page.setRecords(gdPatrolTaskVOS); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List<GdPatrolTaskExcel> exportGdPatrolTask(Wrapper<GdPatrolTaskEntity> queryWrapper) { |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean savePatrolTask(List<GdPatrolTaskEntity> taskEntityList) { |
| | | // 参数校验:防止空指针 |
| | | if (taskEntityList == null || taskEntityList.isEmpty()) { |
| | | throw new RuntimeException("任务列表不能为空"); |
| | | } |
| | | |
| | | // 获取第一个任务的工单ID |
| | | Long workOrderId = taskEntityList.get(0).getWorkOrderId(); |
| | | if (workOrderId == null) { |
| | | throw new RuntimeException("工单ID不能为空"); |
| | | } |
| | | |
| | | // 查询工单信息 |
| | | GdWorkOrderEntity gdWorkOrderEntity = gdWorkOrderMapper.selectById(workOrderId); |
| | | if (gdWorkOrderEntity == null) { |
| | | throw new RuntimeException("工单不存在,工单ID: " + workOrderId); |
| | | } |
| | | |
| | | // 更新流程节点 |
| | | for (GdPatrolTaskEntity gdPatrolTaskEntity : taskEntityList) { |
| | | if (gdPatrolTaskEntity == null) { |
| | | log.warn("跳过空任务对象"); |
| | | continue; |
| | | } |
| | | |
| | | // 设置航线ID |
| | | gdPatrolTaskEntity.setAirlineId(gdPatrolTaskEntity.getPatrolRouteUrl()); |
| | | // 生成巡查任务编号 |
| | | if (StringUtils.isBlank(gdPatrolTaskEntity.getTaskNo())) { |
| | | // 使用时间戳生成唯一巡查任务编号 |
| | | String timestamp = OrderNumUtils.initOrderNum(WordOrderConstant.PATROL_TASK_KEY); |
| | | gdPatrolTaskEntity.setTaskNo(WordOrderConstant.PATROL_TASK_PREFIX + timestamp); |
| | | } |
| | | |
| | | // 从工单实体中获取区域编码,防止空指针 |
| | | String areaCode = gdWorkOrderEntity.getAreaCode(); |
| | | gdPatrolTaskEntity.setAreaCode(areaCode != null ? areaCode : ""); |
| | | // 设置初始状态为待签收(对应流程图:等待接单) |
| | | gdPatrolTaskEntity.setTaskStatus(PatrolTaskStatusEnum.PENDING_SIGNING.getValue()); |
| | | |
| | |
| | | |
| | | // 保存流转记录(发布任务,等待接单) |
| | | GdWorkOrderFlowEntity gdWorkOrderFlowEntity = new GdWorkOrderFlowEntity(); |
| | | gdWorkOrderFlowEntity.setCreateUser(AuthUtil.getUserId()); |
| | | gdWorkOrderFlowEntity.setCreateUser(AuthUtil.getUserId() == null ? 0L : AuthUtil.getUserId()); |
| | | gdWorkOrderFlowEntity.setWorkOrderId(gdPatrolTaskEntity.getId()); |
| | | gdWorkOrderFlowEntity.setFlowName(PatrolTaskStatusEnum.PENDING_SIGNING.getStageDesc()); |
| | | gdWorkOrderFlowEntity.setFlowDesc(PatrolTaskStatusEnum.PENDING_SIGNING.getStageDesc()); |
| | | gdWorkOrderFlowEntity.setOperator(AuthUtil.getNickName()); |
| | | gdWorkOrderFlowEntity.setOperator(StringUtil.isBlank(AuthUtil.getNickName()) ? "系统" : AuthUtil.getNickName()); |
| | | gdWorkOrderFlowEntity.setType(WorkOrderTypeEnum.PATROL_TASK.getValue()); |
| | | gdWorkOrderFlowEntity.setAreaCode(gdPatrolTaskEntity.getAreaCode()); |
| | | gdWorkOrderFlowEntity.setCreateDept(Long.valueOf(AuthUtil.getDeptId())); |
| | | // 使用局部变量areaCode,防止空指针 |
| | | gdWorkOrderFlowEntity.setAreaCode(areaCode != null ? areaCode : ""); |
| | | gdWorkOrderFlowEntity.setCreateDept(Long.valueOf(StringUtil.isBlank(AuthUtil.getDeptId()) ? "0" : AuthUtil.getDeptId())); |
| | | boolean save1 = gdWorkOrderFlowService.save(gdWorkOrderFlowEntity); |
| | | if (!save1) { |
| | | // 流转记录保存失败,抛出异常触发回滚 |
| | |
| | | // 4. 更新任务状态 |
| | | Date now = new Date(); |
| | | task.setTaskStatus(newStatusEnum.getValue()); |
| | | task.setUpdateUser(AuthUtil.getUserId()); |
| | | task.setUpdateUser(AuthUtil.getUserId() == null ? 0L : AuthUtil.getUserId()); |
| | | task.setUpdateTime(now); |
| | | task.setRejectReason(auditParam.getRejectReason()); |
| | | boolean updateResult = updateById(task); |
| | |
| | | // 6. 判断是否审核成功,如果是,需要判断是否整个订单的子任务都审核成功了,除了被撤回和验收拒绝的 |
| | | if (auditStatus == 4) { |
| | | // 将审核后的任务信息推送到星图 |
| | | pushXingtuFlyTask(auditParam.getId()); |
| | | R pushResult = pushXingtuFlyTask(auditParam.getId()); |
| | | // 检查推送结果,如果失败则抛出异常回滚事务 |
| | | if (pushResult != null && !pushResult.isSuccess()) { |
| | | String errorMsg = pushResult.getMsg(); |
| | | log.error("推送星图飞行任务失败: {}", errorMsg); |
| | | throw new RuntimeException(errorMsg + ",请更改执行时间重新提交。"); |
| | | } |
| | | // 查询同一个工单下的所有子任务 |
| | | List<GdPatrolTaskEntity> subTasks = list(Wrappers.<GdPatrolTaskEntity>lambdaQuery() |
| | | .eq(GdPatrolTaskEntity::getWorkOrderId, task.getWorkOrderId())); |
| | | |
| | | // 检查是否所有子任务都审核成功(除了被撤回和验收拒绝的) |
| | | boolean allSubTasksAudited = subTasks.stream() |
| | | // 过滤掉当前任务本身 |
| | | .filter(subTask -> !subTask.getId().equals(task.getId())) |
| | | .map(GdPatrolTaskEntity::getTaskStatus) |
| | | .filter(Objects::nonNull) |
| | | // 过滤掉撤回或验收拒绝的任务 |
| | | .filter(status -> !status.equals(PatrolTaskStatusEnum.WITHDRAWN.getValue()) && |
| | | !status.equals(PatrolTaskStatusEnum.REJECTED_ACCEPTANCE.getValue())) |
| | | // 判断是否有小于待审核的任务 |
| | | .anyMatch(status -> status.compareTo(PatrolTaskStatusEnum.PENDING_AUDIT.getValue()) < 0); |
| | | boolean allSubTasksAudited = isAllSubTasksAudited(subTasks, task, PatrolTaskStatusEnum.PENDING_AUDIT); |
| | | if (!allSubTasksAudited) { |
| | | // 执行工单状态更新逻辑 |
| | | return updateWorkOrderStatusAndFlow(task.getWorkOrderId(), |
| | |
| | | } |
| | | } |
| | | if (auditStatus == 3) { |
| | | // 查询同一个工单下的所有子任务 |
| | | // 撤回任务操作:查询同一个工单下的所有子任务 |
| | | List<GdPatrolTaskEntity> subTasks = list(Wrappers.<GdPatrolTaskEntity>lambdaQuery() |
| | | .eq(GdPatrolTaskEntity::getWorkOrderId, task.getWorkOrderId())); |
| | | |
| | | // 检查是否所有子任务都已撤回 |
| | | boolean allSubTasksWithdrawn = subTasks.stream() |
| | | .allMatch(item -> item.getTaskStatus().equals(PatrolTaskStatusEnum.WITHDRAWN.getValue())); |
| | | |
| | | // 示例:如果所有子任务都审核成功,可以更新工单状态为已完成 |
| | | // 如果所有子任务都已撤回,则将工单状态更新为"接单响应_已取消" |
| | | if (allSubTasksWithdrawn) { |
| | | // 执行工单状态更新逻辑 |
| | | return updateWorkOrderStatusAndFlow(task.getWorkOrderId(), |
| | | WorkOrderStatusEnum.RESPONDING_CANCELED); |
| | | } |
| | |
| | | .eq(GdPatrolTaskEntity::getWorkOrderId, task.getWorkOrderId())); |
| | | |
| | | // 检查是否所有子任务都验收通过(除了被撤回和验收拒绝的) |
| | | boolean allSubTasksAudited = subTasks.stream() |
| | | // 过滤掉当前任务本身 |
| | | .filter(subTask -> !subTask.getId().equals(task.getId())) |
| | | .map(GdPatrolTaskEntity::getTaskStatus) |
| | | .filter(Objects::nonNull) |
| | | // 过滤掉撤回或验收拒绝的任务 |
| | | .filter(status -> !status.equals(PatrolTaskStatusEnum.WITHDRAWN.getValue()) && |
| | | !status.equals(PatrolTaskStatusEnum.REJECTED_ACCEPTANCE.getValue())) |
| | | // 判断是否有小于验收通过的任务 |
| | | .anyMatch(status -> status.compareTo(PatrolTaskStatusEnum.ACCEPTANCE_PASSED.getValue()) < 0); |
| | | boolean allSubTasksAudited = isAllSubTasksAudited(subTasks, task, PatrolTaskStatusEnum.ACCEPTANCE_PASSED); |
| | | // 这里可以根据allSubTasksAudited的结果执行后续逻辑,比如更新工单状态等 |
| | | if (!allSubTasksAudited) { |
| | | // 1.验收通过,生成报告 |
| | |
| | | } |
| | | } |
| | | return b; |
| | | } |
| | | |
| | | /** |
| | | * @param subTasks |
| | | * @param task |
| | | * @param pendingAudit |
| | | * @return |
| | | */ |
| | | private static boolean isAllSubTasksAudited(List<GdPatrolTaskEntity> subTasks, GdPatrolTaskEntity task, PatrolTaskStatusEnum pendingAudit) { |
| | | List<String> validStatusList = subTasks.stream() |
| | | // 过滤掉当前任务本身 |
| | | .filter(subTask -> !subTask.getId().equals(task.getId())) |
| | | .map(GdPatrolTaskEntity::getTaskStatus) |
| | | .filter(Objects::nonNull) |
| | | // 过滤掉撤回或验收拒绝的任务 |
| | | .filter(status -> !status.equals(PatrolTaskStatusEnum.WITHDRAWN.getValue()) && |
| | | !status.equals(PatrolTaskStatusEnum.REJECTED_ACCEPTANCE.getValue())) |
| | | .collect(Collectors.toList()); |
| | | |
| | | // 如果过滤后没有有效任务,直接返回false |
| | | if (validStatusList.isEmpty()) { |
| | | return false; |
| | | } |
| | | |
| | | // 判断是否有小于待审核的任务 |
| | | boolean allSubTasksAudited = validStatusList.stream() |
| | | .anyMatch(status -> status.compareTo(pendingAudit.getValue()) < 0); |
| | | return allSubTasksAudited; |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | // 2. 保存流转记录 |
| | | GdWorkOrderFlowEntity flowEntity = new GdWorkOrderFlowEntity(); |
| | | flowEntity.setCreateUser(AuthUtil.getUserId()); |
| | | flowEntity.setCreateUser(AuthUtil.getUserId() == null ? 0L : AuthUtil.getUserId()); |
| | | flowEntity.setWorkOrderId(workOrderId); |
| | | flowEntity.setFlowName(newStatus.getStageDesc()); |
| | | flowEntity.setFlowDesc(newStatus.getDesc()); |
| | | flowEntity.setOperator(AuthUtil.getNickName()); |
| | | flowEntity.setOperator(StringUtil.isBlank(AuthUtil.getNickName()) ? "系统" : AuthUtil.getNickName()); |
| | | flowEntity.setType(WorkOrderTypeEnum.WORK_ORDER_TASK.getValue()); |
| | | flowEntity.setFlowStatus(newStatus.getMaxCode()); |
| | | flowEntity.setWorkStatus(newStatus.getCode()); |
| | | flowEntity.setCreateDept(Long.valueOf(AuthUtil.getDeptId())); |
| | | flowEntity.setCreateDept(Long.valueOf(StringUtil.isBlank(AuthUtil.getDeptId()) ? "0" : AuthUtil.getDeptId())); |
| | | return gdWorkOrderFlowService.save(flowEntity); |
| | | } |
| | | |
| | |
| | | targetStatus = PatrolTaskStatusEnum.PENDING_AUDIT; |
| | | break; |
| | | default: |
| | | // 其他状态,保持原有状态 |
| | | targetStatus = PatrolTaskStatusEnum.getByValue(currentStatus); |
| | | // 如果无法获取枚举,使用待签收作为默认状态 |
| | | if (targetStatus == null) { |
| | | targetStatus = PatrolTaskStatusEnum.PENDING_SIGNING; |
| | | } |
| | | break; |
| | | // 其他状态,保持原有状态 |
| | | targetStatus = PatrolTaskStatusEnum.getByValue(currentStatus); |
| | | // 如果无法获取枚举,使用待签收作为默认状态 |
| | | if (targetStatus == null) { |
| | | targetStatus = PatrolTaskStatusEnum.PENDING_SIGNING; |
| | | } |
| | | } |
| | | |
| | | // 3. 设置任务状态:使用枚举设置任务状态 |
| | | taskEntity.setTaskStatus(targetStatus.getValue()); |
| | | |
| | | // 4. 更新任务信息:合并传入的任务信息 |
| | | taskEntity.setUpdateUser(AuthUtil.getUserId()); |
| | | taskEntity.setUpdateUser(AuthUtil.getUserId() == null ? 0L : AuthUtil.getUserId()); |
| | | taskEntity.setUpdateTime(new Date()); |
| | | |
| | | // 5. 更新数据库 |
| | |
| | | |
| | | // 6. 保存流转记录:使用枚举设置flowName |
| | | GdWorkOrderFlowEntity flowEntity = new GdWorkOrderFlowEntity(); |
| | | flowEntity.setCreateUser(AuthUtil.getUserId()); |
| | | flowEntity.setCreateUser(AuthUtil.getUserId() == null ? 0L : AuthUtil.getUserId()); |
| | | flowEntity.setWorkOrderId(taskEntity.getId()); |
| | | flowEntity.setFlowName(targetStatus.getDesc()); |
| | | flowEntity.setFlowDesc(AuthUtil.getNickName() + " " + DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss") + " 更新了任务信息,状态转换为:" + targetStatus.getDesc()); |
| | | flowEntity.setOperator(AuthUtil.getNickName()); |
| | | flowEntity.setFlowDesc((StringUtil.isBlank(AuthUtil.getNickName()) ? "系统" : AuthUtil.getNickName()) + " " + DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss") + " 更新了任务信息,状态转换为:" + targetStatus.getDesc()); |
| | | flowEntity.setOperator(StringUtil.isBlank(AuthUtil.getNickName()) ? "系统" : AuthUtil.getNickName()); |
| | | flowEntity.setType(WorkOrderTypeEnum.PATROL_TASK.getValue()); |
| | | flowEntity.setAreaCode(existingTask.getAreaCode()); |
| | | flowEntity.setCreateDept(Long.valueOf(AuthUtil.getDeptId())); |
| | | flowEntity.setCreateDept(Long.valueOf(StringUtil.isBlank(AuthUtil.getDeptId()) ? "0" : AuthUtil.getDeptId())); |
| | | |
| | | return gdWorkOrderFlowService.save(flowEntity); |
| | | } |
| | |
| | | private boolean saveWorkOrderFlow(Long workOrderId, PatrolTaskStatusEnum newStatus, |
| | | String rejectReason, String areaCode) { |
| | | GdWorkOrderFlowEntity flowEntity = new GdWorkOrderFlowEntity(); |
| | | flowEntity.setCreateUser(AuthUtil.getUserId()); |
| | | flowEntity.setCreateUser(AuthUtil.getUserId() == null ? 0L : AuthUtil.getUserId()); |
| | | flowEntity.setWorkOrderId(workOrderId); |
| | | flowEntity.setFlowName(newStatus.getStageDesc()); |
| | | flowEntity.setFlowDesc(newStatus.getStageDesc()); |
| | | flowEntity.setOperator(AuthUtil.getNickName()); |
| | | flowEntity.setOperator(StringUtil.isBlank(AuthUtil.getNickName()) ? "系统" : AuthUtil.getNickName()); |
| | | flowEntity.setType(WorkOrderTypeEnum.PATROL_TASK.getValue()); |
| | | flowEntity.setAreaCode(areaCode); |
| | | flowEntity.setCreateDept(Long.valueOf(AuthUtil.getDeptId())); |
| | | flowEntity.setCreateDept(Long.valueOf(StringUtil.isBlank(AuthUtil.getDeptId()) ? "0" : AuthUtil.getDeptId())); |
| | | |
| | | boolean saveResult = gdWorkOrderFlowService.save(flowEntity); |
| | | if (!saveResult) { |
| | |
| | | if (bladeFile == null || StringUtil.isBlank(bladeFile.getLink())) { |
| | | throw new RuntimeException("附件上传失败"); |
| | | } |
| | | Integer resultType = parseResultType(taskEntity != null ? taskEntity.getPatrolTaskType() : null); |
| | | Attach attach = buildAttachInfo(taskEntity, reportFile, bladeFile, resultType, desiredName); |
| | | // Integer resultType = parseResultType(taskEntity != null ? taskEntity.getPatrolTaskType() : null); |
| | | Attach attach = buildAttachInfo(taskEntity, reportFile, bladeFile, taskEntity.getPatrolTaskType(), desiredName); |
| | | Boolean saved = attachClient.saveAttachInfo(attach); |
| | | if (!Boolean.TRUE.equals(saved)) { |
| | | log.error("附件信息保存失败,报告文件:" + desiredName); |
| | |
| | | * @param desiredName 期望文件名 |
| | | * @return 附件信息 |
| | | */ |
| | | private Attach buildAttachInfo(GdPatrolTaskEntity taskEntity, File reportFile, BladeFile bladeFile, Integer resultType, String desiredName) { |
| | | private Attach buildAttachInfo(GdPatrolTaskEntity taskEntity, File reportFile, BladeFile bladeFile, List<List<String>> resultType, String desiredName) { |
| | | Attach attach = new Attach(); |
| | | attach.setDomainUrl(bladeFile.getDomain()); |
| | | attach.setLink(bladeFile.getLink()); |
| | |
| | | Long updateUser = taskEntity != null ? taskEntity.getUpdateUser() : null; |
| | | Long createDept = taskEntity != null ? taskEntity.getCreateDept() : null; |
| | | if (createUser == null) { |
| | | createUser = AuthUtil.getUserId(); |
| | | createUser = AuthUtil.getUserId() == null ? 0L : AuthUtil.getUserId(); |
| | | } |
| | | if (updateUser == null) { |
| | | updateUser = createUser; |
| | | } |
| | | if (createDept == null) { |
| | | createDept = Long.valueOf(AuthUtil.getDeptId()); |
| | | createDept = Long.valueOf(StringUtil.isBlank(AuthUtil.getDeptId()) ? "0" : AuthUtil.getDeptId()); |
| | | } |
| | | Date now = new Date(); |
| | | attach.setCreateUser(createUser); |
| | |
| | | return R.fail("巡查任务不存在"); |
| | | } |
| | | GdXingtuFlyTaskSaveDTO param = buildXingtuFlyTask(taskEntity); |
| | | return jianXingtuApiService.saveFlyTask(param); |
| | | return jianXingtuApiService.saveFlyTask(param); |
| | | } |
| | | |
| | | /** |
| | |
| | | } else if (StringUtil.isNotBlank(gdPatrolTaskVO.getTaskNo())) { |
| | | param.setName(gdPatrolTaskVO.getTaskNo()); |
| | | } |
| | | if (StringUtil.isNotBlank(gdPatrolTaskVO.getPatrolTaskType())) { |
| | | param.setInspectionType(gdPatrolTaskVO.getPatrolTaskType()); |
| | | } |
| | | // if (StringUtil.isNotBlank(gdPatrolTaskVO.getPatrolTaskType())) { |
| | | // param.setInspectionType(gdPatrolTaskVO.getPatrolTaskType()); |
| | | // } |
| | | if ((gdPatrolTaskVO.getId() != null)) { |
| | | param.setPatrolTaskld(String.valueOf(gdPatrolTaskVO.getId())); |
| | | param.setPatrolTaskId(String.valueOf(gdPatrolTaskVO.getId())); |
| | | } |
| | | param.setTimingType("单次执行"); |
| | | if (StringUtil.isNotBlank(gdPatrolTaskVO.getAirlineId())) { |
| | |
| | | } |
| | | if (gdPatrolTaskVO.getExecuteTime() != null) { |
| | | param.setSingleTime(DateUtil.format(gdPatrolTaskVO.getExecuteTime(), "yyyy-MM-dd HH:mm:ss")); |
| | | } |
| | | } |
| | | if (StringUtil.isNotBlank(gdPatrolTaskVO.getAreaCode())) { |
| | | param.setRegionCode(gdPatrolTaskVO.getAreaCode()); |
| | | // regionCode : "3600,3608,360802" |
| | | String regionCode = convertAreaCodeToRegionCode(gdPatrolTaskVO.getAreaCode()); |
| | | param.setRegionCode(regionCode); |
| | | } |
| | | if (StringUtil.isNotBlank(gdPatrolTaskVO.getAirportId())) { |
| | | param.setAirportId(gdPatrolTaskVO.getAirportId()); |
| | | } |
| | | if (StringUtil.isNotBlank(gdPatrolTaskVO.getDeviceFlyerId())) { |
| | | param.setDeviceFlyerId(gdPatrolTaskVO.getDeviceFlyerId()); |
| | | } |
| | | if (gdPatrolTaskVO.getAlgorithmIds() != null && !gdPatrolTaskVO.getAlgorithmIds().isEmpty()) { |
| | | // 将 List<String> 转换为逗号分隔的字符串 |
| | | String algorithmIdStr = String.join(",", gdPatrolTaskVO.getAlgorithmIds()); |
| | | param.setAlgorithmId(algorithmIdStr); |
| | | } |
| | | // 机构 |
| | | param.setDeptId(gdPatrolTaskVO.getCreateDept()); |
| | | // 巡检类型 |
| | | param.setInspectionTypeArr(gdPatrolTaskVO.getPatrolTaskType()); |
| | | // param.setInspectionType(gdPatrolTaskVO.getPatrolTaskType()); |
| | | // 机巢名称 |
| | | param.setAirportName(gdPatrolTaskVO.getDeviceName()); |
| | | param.setStatus("待执行"); |
| | | param.setTaskType("航线飞行"); |
| | | param.setTaskType("定时飞行"); |
| | | return param; |
| | | } |
| | | |
| | |
| | | // 1. 更新当前任务状态 |
| | | boolean updateResult = updateById(auditParam); |
| | | if (!updateResult) { |
| | | log.warn("更新任务失败,任务ID: {}"); |
| | | log.warn("更新任务失败,任务ID: {}", auditParam.getId()); |
| | | return false; |
| | | } |
| | | |
| | |
| | | GdPatrolTaskEntity patrolTaskEntity = Optional.ofNullable(getById(auditParam.getId())) |
| | | .orElseThrow(() -> new RuntimeException("任务不存在,任务ID: " + auditParam.getId())); |
| | | |
| | | // 3. 保存巡查工单流转 |
| | | saveWorkOrderFlow(patrolTaskEntity.getWorkOrderId(), PatrolTaskStatusEnum.PENDING_ACCEPTANCE, null, null); |
| | | // 3. 保存巡查工单流转(使用传入的实际状态) |
| | | PatrolTaskStatusEnum statusEnum = PatrolTaskStatusEnum.getByValue(auditParam.getTaskStatus()); |
| | | if (statusEnum != null) { |
| | | saveWorkOrderFlow(patrolTaskEntity.getId(), statusEnum, null, patrolTaskEntity.getAreaCode()); |
| | | } |
| | | |
| | | // 4. 查询同一个工单下的所有子任务 |
| | | List<GdPatrolTaskEntity> subTasks = list(Wrappers.<GdPatrolTaskEntity>lambdaQuery() |
| | |
| | | return updateResult; |
| | | } |
| | | |
| | | @Override |
| | | public List<GdPatrolTaskSimpleVO> selectListByWorkOrderId(Long workOrderId) { |
| | | return baseMapper.selectListByWorkOrderId(workOrderId); |
| | | } |
| | | |
| | | /** |
| | | * 查询待验收状态的巡查任务列表(对外接口) |
| | | * |
| | | * @param queryParam 查询参数,包含任务名称和时间区间 |
| | | * @return 待验收状态的巡查任务列表 |
| | | */ |
| | | @Override |
| | | public List<GdPatrolTaskVO> selectPendingAcceptanceTasks(GdPatrolTaskPendingAcceptanceQueryParam queryParam) { |
| | | // 1. 参数校验:防止空指针 |
| | | if (queryParam == null) { |
| | | queryParam = new GdPatrolTaskPendingAcceptanceQueryParam(); |
| | | } |
| | | |
| | | // 2. 调用Mapper查询待验收状态的巡查任务 |
| | | List<GdPatrolTaskVO> pendingAcceptanceTasks = baseMapper.selectPendingAcceptanceTasks(queryParam); |
| | | |
| | | // 3. 返回查询结果 |
| | | return pendingAcceptanceTasks; |
| | | } |
| | | |
| | | /** |
| | | * 将区域编码转换为多级行政区划编码格式 |
| | | * |
| | | * @param areaCode 区域编码(如:360802) |
| | | * @return 多级行政区划编码,格式为 "省编码,市编码,区编码"(如:"3600,3608,360802") |
| | | */ |
| | | private String convertAreaCodeToRegionCode(String areaCode) { |
| | | if (StringUtil.isBlank(areaCode)) { |
| | | return null; |
| | | } |
| | | |
| | | // 如果已经是逗号分隔的格式,直接返回 |
| | | if (areaCode.contains(",")) { |
| | | return areaCode; |
| | | } |
| | | |
| | | // 去除空格并确保长度为6位 |
| | | String cleanCode = areaCode.trim(); |
| | | // 如果长度大于6位,只取前6位 |
| | | if (cleanCode.length() > 6) { |
| | | log.warn("区域编码长度超过6位,截取前6位: {}", cleanCode); |
| | | cleanCode = cleanCode.substring(0, 6); |
| | | } |
| | | if (cleanCode.length() != 6) { |
| | | log.warn("区域编码格式不正确,期望6位数字,实际为: {}", cleanCode); |
| | | return cleanCode; |
| | | } |
| | | |
| | | try { |
| | | // 提取省、市、区三级编码 |
| | | String provinceCode = cleanCode.substring(0, 2) + "00"; // 省级编码(如:3600) |
| | | String cityCode = cleanCode.substring(0, 4); // 市级编码(如:3608) |
| | | String districtCode = cleanCode; // 区级编码(如:360802) |
| | | |
| | | return provinceCode + "," + cityCode + "," + districtCode; |
| | | } catch (Exception e) { |
| | | log.error("区域编码转换失败: {}", e.getMessage()); |
| | | return areaCode; |
| | | } |
| | | } |
| | | |
| | | } |