| | |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.utils.DateUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.sxkj.common.constant.WordOrderConstant; |
| | |
| | | import org.springblade.core.tool.constant.BladeConstant; |
| | | import org.springblade.core.tool.utils.FileUtil; |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | | import org.sxkj.gd.workorder.dto.GdXingtuFlyTaskSaveDTO; |
| | | import org.sxkj.gd.workorder.entity.GdManageDeviceEntity; |
| | | import org.sxkj.gd.workorder.entity.GdPatrolTaskEntity; |
| | | import org.sxkj.gd.workorder.entity.GdTaskResultEntity; |
| | | import org.sxkj.gd.workorder.entity.GdWorkOrderEntity; |
| | |
| | | import org.sxkj.gd.workorder.param.GdPatrolTaskAuditParam; |
| | | import org.sxkj.gd.workorder.param.GdPatrolTaskPageParam; |
| | | import org.sxkj.gd.workorder.service.IGdPatrolTaskService; |
| | | import org.sxkj.gd.workorder.service.IGdManageDeviceService; |
| | | 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.GdPatrolTaskVO; |
| | | import org.sxkj.gd.common.GdMultipartFileUtil; |
| | | import org.sxkj.gd.xingtu.JianXingtuApiService; |
| | | import org.sxkj.resource.entity.Attach; |
| | | import org.sxkj.resource.feign.IAttachClient; |
| | | import org.sxkj.system.cache.SysCache; |
| | | import org.sxkj.system.entity.Dept; |
| | | import org.sxkj.system.entity.User; |
| | | import org.sxkj.system.feign.ISysClient; |
| | |
| | | @Service |
| | | public class GdPatrolTaskServiceImpl extends BaseServiceImpl<GdPatrolTaskMapper, GdPatrolTaskEntity> implements IGdPatrolTaskService { |
| | | |
| | | @Autowired |
| | | private IGdWorkOrderFlowService gdWorkOrderFlowService; |
| | | @Autowired |
| | | private IGdWorkOrderFlowService gdWorkOrderFlowService; |
| | | |
| | | // @Autowired |
| | | // private IGdWorkOrderService gdWorkOrderService; |
| | | // @Autowired |
| | | // private IGdWorkOrderService gdWorkOrderService; |
| | | @Autowired |
| | | private ISysClient sysClient; |
| | | @Autowired |
| | |
| | | private IAttachClient attachClient; |
| | | @Autowired |
| | | private IGdTaskResultService gdTaskResultService; |
| | | @Autowired |
| | | private JianXingtuApiService jianXingtuApiService; |
| | | @Autowired |
| | | private IGdManageDeviceService gdManageDeviceService; |
| | | @Override |
| | | public IPage<GdPatrolTaskVO> selectGdPatrolTaskPage(IPage<GdPatrolTaskVO> page, GdPatrolTaskPageParam gdPatrolTask, List<Long> deptIdList) { |
| | | return page.setRecords(baseMapper.selectGdPatrolTaskPage(page, gdPatrolTask, deptIdList)); |
| | | public IPage<GdPatrolTaskVO> selectGdPatrolTaskPage(IPage<GdPatrolTaskVO> page, GdPatrolTaskPageParam gdPatrolTask) { |
| | | List<Long> deptList = SysCache.getDeptChildIds(Long.valueOf(AuthUtil.getDeptId())); |
| | | gdPatrolTask.setDeptList(deptList); |
| | | return page.setRecords(baseMapper.selectGdPatrolTaskPage(page, gdPatrolTask)); |
| | | } |
| | | |
| | | |
| | |
| | | gdWorkOrderFlowEntity.setWorkOrderId(gdPatrolTaskEntity.getId()); |
| | | gdWorkOrderFlowEntity.setFlowName(PatrolTaskStatusEnum.PENDING_SIGNING.getStageDesc()); |
| | | gdWorkOrderFlowEntity.setFlowDesc(AuthUtil.getUserName() + " " + DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss") + " 发布任务,等待接单"); |
| | | gdWorkOrderFlowEntity.setOperator(AuthUtil.getUserName()); |
| | | gdWorkOrderFlowEntity.setOperator(AuthUtil.getNickName()); |
| | | gdWorkOrderFlowEntity.setType(WorkOrderTypeEnum.PATROL_TASK.getValue()); |
| | | gdWorkOrderFlowEntity.setAreaCode(gdPatrolTaskEntity.getAreaCode()); |
| | | gdWorkOrderFlowEntity.setCreateDept(Long.valueOf(AuthUtil.getDeptId())); |
| | |
| | | boolean b = saveWorkOrderFlow(task.getId(), newStatusEnum, auditParam.getRejectReason(), task.getAreaCode()); |
| | | // 6. 判断是否审核成功,如果是,需要判断是否整个订单的子任务都审核成功了,除了被撤回和验收拒绝的 |
| | | if (auditStatus == 4) { |
| | | //将审核后的任务信息推送到星图 |
| | | pushXingtuFlyTask(auditParam.getId()); |
| | | // 查询同一个工单下的所有子任务 |
| | | List<GdPatrolTaskEntity> subTasks = list(Wrappers.<GdPatrolTaskEntity>lambdaQuery() |
| | | .eq(GdPatrolTaskEntity::getWorkOrderId, task.getWorkOrderId())); |
| | |
| | | boolean allSubTasksAudited = checkAllSubTasksStatus(subTasks, PatrolTaskStatusEnum.ACCEPTANCE_PASSED); |
| | | // 这里可以根据allSubTasksAudited的结果执行后续逻辑,比如更新工单状态等 |
| | | if (allSubTasksAudited) { |
| | | // 执行工单状态更新逻辑 |
| | | // 1.验收通过,生成报告 |
| | | asyncExportPatrolReport(task.getId()); |
| | | // 2.执行工单状态更新逻辑 |
| | | return updateWorkOrderStatusAndFlow(task.getWorkOrderId(), |
| | | WorkOrderStatusEnum.ACCEPTED_TO_BE_SETTLED); |
| | | } |
| | |
| | | GdWorkOrderFlowEntity flowEntity = new GdWorkOrderFlowEntity(); |
| | | flowEntity.setCreateUser(AuthUtil.getUserId()); |
| | | flowEntity.setWorkOrderId(workOrderId); |
| | | flowEntity.setFlowName(newStatus.getDesc()); |
| | | flowEntity.setFlowDesc(String.format("%s %s 更新了任务信息,状态转换为:%s", |
| | | AuthUtil.getUserName(), |
| | | DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"), |
| | | newStatus.getDesc())); |
| | | flowEntity.setOperator(AuthUtil.getUserName()); |
| | | flowEntity.setFlowName(newStatus.getStageDesc()); |
| | | flowEntity.setFlowDesc(newStatus.getDesc()); |
| | | flowEntity.setOperator(AuthUtil.getNickName()); |
| | | flowEntity.setType(WorkOrderTypeEnum.WORK_ORDER_TASK.getValue()); |
| | | flowEntity.setFlowStatus(newStatus.getMaxCode()); |
| | | flowEntity.setWorkStatus(newStatus.getCode()); |
| | | flowEntity.setCreateDept(Long.valueOf(AuthUtil.getDeptId())); |
| | | return gdWorkOrderFlowService.save(flowEntity); |
| | | } |
| | |
| | | flowEntity.setCreateUser(AuthUtil.getUserId()); |
| | | flowEntity.setWorkOrderId(taskEntity.getId()); |
| | | flowEntity.setFlowName(targetStatus.getDesc()); |
| | | flowEntity.setFlowDesc(AuthUtil.getUserName() + " " + DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss") + " 更新了任务信息,状态转换为:" + targetStatus.getDesc()); |
| | | flowEntity.setOperator(AuthUtil.getUserName()); |
| | | flowEntity.setFlowDesc(AuthUtil.getNickName() + " " + DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss") + " 更新了任务信息,状态转换为:" + targetStatus.getDesc()); |
| | | flowEntity.setOperator(AuthUtil.getNickName()); |
| | | flowEntity.setType(WorkOrderTypeEnum.PATROL_TASK.getValue()); |
| | | flowEntity.setAreaCode(existingTask.getAreaCode()); |
| | | flowEntity.setCreateDept(Long.valueOf(AuthUtil.getDeptId())); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 异步生成巡查报告 |
| | | * |
| | | * @param patrolTaskId 巡查任务ID |
| | | */ |
| | | @Async |
| | | public void asyncExportPatrolReport(Long patrolTaskId) { |
| | | try { |
| | | exportPatrolReport(patrolTaskId); |
| | | } catch (Exception e) { |
| | | // 记录异步执行错误日志 |
| | | log.error("异步生成巡查报告失败,任务ID: {}"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 检查拒绝原因是否必填 |
| | |
| | | String flowDesc = buildFlowDesc(newStatus, rejectReason); |
| | | flowEntity.setFlowDesc(flowDesc); |
| | | |
| | | flowEntity.setOperator(AuthUtil.getUserName()); |
| | | flowEntity.setOperator(AuthUtil.getNickName()); |
| | | flowEntity.setType(WorkOrderTypeEnum.PATROL_TASK.getValue()); |
| | | flowEntity.setAreaCode(areaCode); |
| | | flowEntity.setCreateDept(Long.valueOf(AuthUtil.getDeptId())); |
| | |
| | | */ |
| | | private String buildFlowDesc(PatrolTaskStatusEnum newStatus, String rejectReason) { |
| | | String baseDesc = String.format("%s %s ", |
| | | AuthUtil.getUserName(), |
| | | AuthUtil.getNickName(), |
| | | DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss")); |
| | | |
| | | // 拒绝类状态需要添加拒绝原因 |
| | |
| | | Attach attach = new Attach(); |
| | | attach.setDomainUrl(bladeFile.getDomain()); |
| | | attach.setLink(bladeFile.getLink()); |
| | | attach.setName(desiredName); |
| | | attach.setOriginalName(desiredName); |
| | | attach.setName(bladeFile.getName()); |
| | | attach.setOriginalName(bladeFile.getOriginalName()); |
| | | attach.setAttachSize(reportFile.length()); |
| | | attach.setExtension(FileUtil.getFileExtension(reportFile.getName())); |
| | | attach.setResultType(resultType); |
| | | attach.setPatrolTaskId(String.valueOf(taskEntity != null ? taskEntity.getId() : null)); |
| | | Long createUser = taskEntity != null ? taskEntity.getCreateUser() : null; |
| | | Long updateUser = taskEntity != null ? taskEntity.getUpdateUser() : null; |
| | | Long createDept = taskEntity != null ? taskEntity.getCreateDept() : null; |
| | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public R pushXingtuFlyTask(Long patrolTaskId) { |
| | | if (patrolTaskId == null) { |
| | | return R.fail("巡查任务主键不能为空"); |
| | | } |
| | | GdPatrolTaskVO taskEntity = baseMapper.getPatrolTaskIdById(patrolTaskId); |
| | | if (taskEntity == null) { |
| | | return R.fail("巡查任务不存在"); |
| | | } |
| | | GdXingtuFlyTaskSaveDTO param = buildXingtuFlyTask(taskEntity); |
| | | return jianXingtuApiService.saveFlyTask(param); |
| | | } |
| | | |
| | | /** |
| | | * 构建巡察任务推送的巡察任务信息 |
| | | * @param gdPatrolTaskVO |
| | | * @return |
| | | */ |
| | | private GdXingtuFlyTaskSaveDTO buildXingtuFlyTask(GdPatrolTaskVO gdPatrolTaskVO) { |
| | | GdXingtuFlyTaskSaveDTO param = new GdXingtuFlyTaskSaveDTO(); |
| | | if (StringUtil.isNotBlank(gdPatrolTaskVO.getPatrolTaskName())) { |
| | | param.setName(gdPatrolTaskVO.getPatrolTaskName()); |
| | | } else if (StringUtil.isNotBlank(gdPatrolTaskVO.getTaskNo())) { |
| | | param.setName(gdPatrolTaskVO.getTaskNo()); |
| | | } |
| | | if (StringUtil.isNotBlank(gdPatrolTaskVO.getPatrolTaskType())) { |
| | | param.setInspectionType(gdPatrolTaskVO.getPatrolTaskType()); |
| | | } |
| | | if ((gdPatrolTaskVO.getId()!=null)) { |
| | | param.setPatrolTaskld(String.valueOf(gdPatrolTaskVO.getId())); |
| | | } |
| | | param.setTimingType("单次执行"); |
| | | if (StringUtil.isNotBlank(gdPatrolTaskVO.getAirlineId())) { |
| | | param.setAirlineId(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()); |
| | | } |
| | | if (StringUtil.isNotBlank(gdPatrolTaskVO.getAirportId())) { |
| | | param.setAirportId(gdPatrolTaskVO.getAirportId()); |
| | | // GdManageDeviceEntity device = null; |
| | | // if (StringUtils.isNumeric(taskEntity.getAirportId())) { |
| | | // device = gdManageDeviceService.getById(Long.valueOf(taskEntity.getDeviceId())); |
| | | // } |
| | | // if (device == null) { |
| | | // device = gdManageDeviceService.lambdaQuery() |
| | | // .eq(GdManageDeviceEntity::getAirportId, taskEntity.getDeviceId()) |
| | | // .one(); |
| | | // } |
| | | // if (device != null && StringUtil.isNotBlank(device.getAirportId())) { |
| | | // param.setAirportId(device.getAirportId()); |
| | | // } else { |
| | | // param.setAirportId(taskEntity.getAirportId()); |
| | | // } |
| | | } |
| | | param.setStatus("待执行"); |
| | | param.setTaskType("航线飞行"); |
| | | return param; |
| | | } |
| | | } |