| | |
| | | package com.xiaopeng.maintenance.controller; |
| | | |
| | | |
| | | import cn.afterturn.easypoi.excel.ExcelExportUtil; |
| | | import cn.afterturn.easypoi.excel.entity.ExportParams; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.alibaba.fastjson2.JSONArray; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.xiaopeng.api.dto.account.XpOperationsUserPositionDTO; |
| | | import com.xiaopeng.api.feignClient.account.XpOperationUserClient; |
| | | import com.xiaopeng.api.feignClient.vehicleConvoy.XpFleetClient; |
| | | import com.xiaopeng.api.feignClient.vehicleConvoy.XpFleetOperationsClient; |
| | | import com.xiaopeng.api.feignClient.vehicleConvoy.XpVehicleClient; |
| | | import com.xiaopeng.api.model.account.XpOperationsUser; |
| | | import com.xiaopeng.api.model.maintenance.XpErrorType; |
| | | import com.xiaopeng.api.model.maintenance.XpTask; |
| | | import com.xiaopeng.api.model.maintenance.XpTaskRule; |
| | | import com.xiaopeng.api.model.vehicleConvoy.XpFleet; |
| | | import com.xiaopeng.api.model.vehicleConvoy.XpFleetOperations; |
| | | import com.xiaopeng.api.model.vehicleConvoy.XpVehicle; |
| | | import com.xiaopeng.api.query.account.OptionalUsersPageListQuery; |
| | | import com.xiaopeng.api.vo.XpTaskVO; |
| | | import com.xiaopeng.api.vo.account.LoginOperationUser; |
| | | import com.xiaopeng.api.vo.account.XpOperationsUserWithRoleVO; |
| | | import com.xiaopeng.api.vo.automaticPilot.VehiclePosition; |
| | | import com.xiaopeng.common.core.domain.R; |
| | | import com.xiaopeng.common.core.exception.ServiceException; |
| | | import com.xiaopeng.common.core.web.page.PageInfo; |
| | | import com.xiaopeng.common.log.annotation.AdminOperationLog; |
| | | import com.xiaopeng.common.log.enums.AdminBusinessType; |
| | | import com.xiaopeng.common.log.enums.AdminOperationType; |
| | | import com.xiaopeng.common.security.service.TokenService; |
| | | import com.xiaopeng.evi.oss.service.AliOssService; |
| | | import com.xiaopeng.maintenance.dto.HandleVehicleAccidentDto; |
| | | import com.xiaopeng.maintenance.dto.SaveRoutineDetailDto; |
| | | import com.xiaopeng.maintenance.dto.SaveVehicleAccidentDto; |
| | | import com.xiaopeng.maintenance.job.AccidentTaskQuartzScheduler; |
| | | import com.xiaopeng.maintenance.mapper.XpTaskRuleMapper; |
| | | import com.xiaopeng.maintenance.model.query.TaskPageListQuery; |
| | | import com.xiaopeng.maintenance.model.query.XpTaskRecordPageQuery; |
| | | import com.xiaopeng.maintenance.model.vo.*; |
| | | import com.xiaopeng.maintenance.schedule.InsuranceInspectionScheduleTask; |
| | | import com.xiaopeng.maintenance.service.IXpErrorTypeService; |
| | | import com.xiaopeng.maintenance.service.XpTaskService; |
| | | import com.xiaopeng.maintenance.vo.VehicleListVO; |
| | | import com.xiaopeng.maintenance.vo.*; |
| | | import com.xiaopeng.maintenance.vo.TaskCleanDetailVO; |
| | | import com.xiaopeng.maintenance.vo.TaskDetectionDetailVO; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.apache.shardingsphere.transaction.annotation.ShardingSphereTransactionType; |
| | | import org.apache.shardingsphere.transaction.core.TransactionType; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.domain.Sort; |
| | | import org.springframework.data.geo.Circle; |
| | | import org.springframework.data.geo.Distance; |
| | | import org.springframework.data.geo.Metrics; |
| | | import org.springframework.data.mongodb.core.MongoTemplate; |
| | | import org.springframework.data.mongodb.core.geo.GeoJsonPoint; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.ServletOutputStream; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.validation.Valid; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.io.IOException; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.net.URLEncoder; |
| | | import java.util.*; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @Resource |
| | | private XpTaskService xpTaskService; |
| | | @Resource |
| | | private MongoTemplate mongoTemplate; |
| | | @Resource |
| | | private TokenService tokenService; |
| | | @Resource |
| | | private IXpErrorTypeService xpErrorTypeService; |
| | |
| | | private XpFleetOperationsClient xpFleetOperationsClient; |
| | | @Resource |
| | | private XpVehicleClient xpVehicleClient; |
| | | @ApiOperation(value = "任务中心列表", response = XpErrorType.class, tags = "运维APP-任务中心") |
| | | @GetMapping("/api/v1/task/errorTypeList") |
| | | @Autowired |
| | | private InsuranceInspectionScheduleTask insuranceInspectionScheduleTask; |
| | | @Autowired |
| | | private AliOssService aliOssService; |
| | | |
| | | @Resource |
| | | private XpTaskRuleMapper xpTaskRuleMapper; |
| | | |
| | | @Resource |
| | | private AccidentTaskQuartzScheduler accidentTaskQuartzScheduler; |
| | | |
| | | @Resource |
| | | private XpOperationUserClient operationUserClient; |
| | | |
| | | @Resource |
| | | XpFleetClient xpFleetClient; |
| | | |
| | | @ApiOperation(value = "事故类型列表", response = XpErrorType.class, tags = "运维APP-任务中心") |
| | | @GetMapping("/maintenance-app/api/v1/task/errorTypeList") |
| | | public R<List<XpErrorType>> errorTypeList() { |
| | | return xpErrorTypeService.errorTypeList(); |
| | | } |
| | | |
| | | @ApiOperation(value = "任务中心列表", response = TaskPageListVO.class, tags = "运维APP-任务中心") |
| | | @PostMapping("/api/v1/task/pageList") |
| | | @PostMapping("/maintenance-app/api/v1/task/pageList") |
| | | public R<PageInfo<TaskPageListVO>> pageList(@RequestBody TaskPageListQuery query) { |
| | | query.setUserId(tokenService.getLoginOperationUser().getXpOperationsUser().getId()); |
| | | PageInfo<TaskPageListVO> pageList = xpTaskService.pageList(query); |
| | | return R.ok(pageList); |
| | | } |
| | | @ApiOperation(value = "事故任务确认到达", tags = "运维APP-任务中心") |
| | | @GetMapping("/api/v1/task/confirmArrive") |
| | | @Transactional |
| | | public R confirmArrive( Integer id) { |
| | | return xpTaskService.confirmArrive(id); |
| | | |
| | | @ApiOperation(value = "接收工单", tags = "运维APP-任务中心") |
| | | @PostMapping("/maintenance-app/api/v1/task/accept/{id}") |
| | | public R<?> accept(@PathVariable("id") String id) { |
| | | xpTaskService.accept(id); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @ApiOperation(value = "工单改派", tags = "运维APP-任务中心") |
| | | @PostMapping("/maintenance-app/api/v1/task/reassign") |
| | | public R<?> reassign(@RequestBody TaskReassignVo vo) { |
| | | xpTaskService.reassign(vo.getTaskId(), vo.getComment()); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @ApiOperation(value = "事故任务确认到达", tags = "运维APP-任务中心") |
| | | @GetMapping("/maintenance-app/api/v1/task/confirmArrive") |
| | | public R confirmArrive(Long id) { |
| | | Long userId = tokenService.getLoginOperationUser().getXpOperationsUser().getId(); |
| | | return xpTaskService.confirmArrive(id, userId); |
| | | } |
| | | |
| | | @ApiOperation(value = "查询车辆不分页列表", tags = "运维APP-任务中心") |
| | | @PostMapping("/api/v1/task/listVehicle") |
| | | @PostMapping("/maintenance-app/api/v1/task/listVehicle") |
| | | public R<List<VehicleListVO>> listVehicle() { |
| | | |
| | | LoginOperationUser loginOperationUser = tokenService.getLoginOperationUser(); |
| | | XpOperationsUser xpOperationsUser = loginOperationUser.getXpOperationsUser(); |
| | | // 查询当前人员所属车队 查询车队关联车辆 |
| | | R<List<Long>> vehicleByUserId = xpFleetOperationsClient.getVehicleByUserId(xpOperationsUser.getId()); |
| | | List<Long> vehicleIds = vehicleByUserId.getData(); |
| | | if (vehicleIds != null && !vehicleIds.isEmpty()){ |
| | | // todo 查询车辆列表 获取经纬度 |
| | | if (vehicleIds != null && !vehicleIds.isEmpty()) { |
| | | |
| | | List<XpVehicle> data = xpVehicleClient.listByIds(vehicleIds).getData(); |
| | | if (data!=null){ |
| | | if (data != null) { |
| | | List<VehicleListVO> vehicleListVOS = new ArrayList<>(); |
| | | for (XpVehicle xpVehicle : data) { |
| | | |
| | | VehicleListVO vehicleListVO = new VehicleListVO(); |
| | | vehicleListVO.setId(xpVehicle.getId()); |
| | | // vehicleListVO.setVehicleLon(xpVehicle.getVehicleLon()); |
| | | // vehicleListVO.setVehicleLat(xpVehicle.getVehicleLat()); |
| | | VehiclePosition vehiclePosition = mongoTemplate.findOne(new Query(Criteria.where("vin").is(xpVehicle.getVehicleVin())), VehiclePosition.class); |
| | | if (vehiclePosition != null) { |
| | | double x = vehiclePosition.getPoint().getX(); |
| | | double y = vehiclePosition.getPoint().getY(); |
| | | vehicleListVO.setVehicleLon(x + ""); |
| | | vehicleListVO.setVehicleLat(y + ""); |
| | | } |
| | | vehicleListVO.setVehicleCode(xpVehicle.getVehicleCode()); |
| | | vehicleListVO.setVehicleColor(xpVehicle.getVehicleColor()); |
| | | vehicleListVO.setPlateNumber(xpVehicle.getPlateNumber()); |
| | |
| | | |
| | | return R.ok(new ArrayList<>()); |
| | | } |
| | | |
| | | @ApiOperation(value = "上传车辆事故", tags = "运维APP-任务中心") |
| | | @PostMapping("/api/v1/task/saveVehicleAccident") |
| | | @PostMapping("/maintenance-app/api/v1/task/saveVehicleAccident") |
| | | public R saveVehicleAccident(@RequestBody SaveVehicleAccidentDto dto) { |
| | | LoginOperationUser loginOperationUser = tokenService.getLoginOperationUser(); |
| | | XpOperationsUser xpOperationsUser = loginOperationUser.getXpOperationsUser(); |
| | | xpTaskService.saveVehicleAccident(dto, xpOperationsUser); |
| | | XpTask task = xpTaskService.saveVehicleAccident(dto, xpOperationsUser); |
| | | |
| | | try { |
| | | XpTaskRule taskRule = xpTaskRuleMapper.selectOne(null); |
| | | Integer processingTimeLimit = taskRule == null ? null : taskRule.getProcessingTimeLimit(); |
| | | accidentTaskQuartzScheduler.scheduleAccidentTimeoutJobs(task.getId(), task.getEndTime(), processingTimeLimit); |
| | | } catch (Exception e) { |
| | | log.error("事故任务Quartz调度失败,taskId={}", task == null ? null : task.getId(), e); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | @ApiOperation(value = "车辆事故任务详情", tags = "运维APP-任务中心") |
| | | @GetMapping("/api/v1/task/vehicleAccidentDetail") |
| | | public R<TaskAccidentDetailVO> vehicleAccidentDetail(Long id) { |
| | | @GetMapping("/maintenance-app/api/v1/task/vehicleAccidentDetail") |
| | | public R<TaskAccidentDetailVO> vehicleAccidentDetail(Long id) throws UnsupportedEncodingException { |
| | | return xpTaskService.vehicleAccidentDetail(id); |
| | | } |
| | | |
| | | @ApiOperation(value = "车辆其他常规任务详情", tags = "运维APP-任务中心") |
| | | @GetMapping("/api/v1/task/vehicleRoutineDetail") |
| | | public R<TaskRoutineDetailVO> vehicleRoutineDetail(Long id) { |
| | | @GetMapping("/maintenance-app/api/v1/task/vehicleRoutineDetail") |
| | | public R<TaskRoutineDetailVO> vehicleRoutineDetail(Long id) throws UnsupportedEncodingException { |
| | | return xpTaskService.vehicleRoutineDetail(id); |
| | | } |
| | | |
| | | @ApiOperation(value = "上传车辆其他常规任务详情", tags = "运维APP-任务中心") |
| | | @PostMapping("/api/v1/task/saveRoutineDetail") |
| | | @PostMapping("/maintenance-app/api/v1/task/saveRoutineDetail") |
| | | public R saveRoutineDetail(@RequestBody SaveRoutineDetailDto dto) { |
| | | LoginOperationUser loginOperationUser = tokenService.getLoginOperationUser(); |
| | | Long id = loginOperationUser.getId(); |
| | | return xpTaskService.saveRoutineDetail(dto, id); |
| | | } |
| | | |
| | | @ApiOperation(value = "车辆常规充电任务详情", tags = "运维APP-任务中心") |
| | | @GetMapping("/api/v1/task/chargingDetail") |
| | | @GetMapping("/maintenance-app/api/v1/task/chargingDetail") |
| | | public R<TaskChargingDetailVO> chargingDetail(Long id) { |
| | | return xpTaskService.chargingDetail(id); |
| | | } |
| | | |
| | | @ApiOperation(value = "车辆常规维修任务详情", tags = "运维APP-任务中心") |
| | | @GetMapping("/api/v1/task/repairDetail") |
| | | public R<com.xiaopeng.maintenance.vo.TaskRepairDetailVO> repairDetail(Long id) { |
| | | @GetMapping("/maintenance-app/api/v1/task/repairDetail") |
| | | public R<TaskRepairDetailVO> repairDetail(Long id) { |
| | | return xpTaskService.repairDetail(id); |
| | | } |
| | | |
| | | @ApiOperation(value = "车辆常规整备任务详情", tags = "运维APP-任务中心") |
| | | @GetMapping("/api/v1/task/preparationDetail") |
| | | public R<com.xiaopeng.maintenance.vo.TaskPreparationDetailVO> preparationDetail(Long id) { |
| | | @GetMapping("/maintenance-app/api/v1/task/preparationDetail") |
| | | public R<TaskPreparationDetailVO> preparationDetail(Long id) { |
| | | return xpTaskService.preparationDetail(id); |
| | | } |
| | | |
| | | @ApiOperation(value = "车辆常规检测任务详情", tags = "运维APP-任务中心") |
| | | @GetMapping("/api/v1/task/detectionDetail") |
| | | public R<com.xiaopeng.maintenance.vo.TaskDetectionDetailVO> detectionDetail(Long id) { |
| | | @GetMapping("/maintenance-app/api/v1/task/detectionDetail") |
| | | public R<TaskDetectionDetailVO> detectionDetail(Long id) { |
| | | return xpTaskService.detectionDetail(id); |
| | | } |
| | | |
| | | @ApiOperation(value = "车辆常规洗车任务详情", tags = "运维APP-任务中心") |
| | | @GetMapping("/api/v1/task/cleanDetail") |
| | | public R<com.xiaopeng.maintenance.vo.TaskCleanDetailVO> cleanDetail(Long id) { |
| | | @GetMapping("/maintenance-app/api/v1/task/cleanDetail") |
| | | public R<TaskCleanDetailVO> cleanDetail(Long id) throws UnsupportedEncodingException { |
| | | return xpTaskService.cleanDetail(id); |
| | | } |
| | | @ApiOperation(value = "处理车辆事故", tags = "运维APP-任务中心") |
| | | @PostMapping("/api/v1/task/handleVehicleAccident") |
| | | |
| | | @Transactional |
| | | @ShardingSphereTransactionType(TransactionType.BASE) |
| | | @ApiOperation(value = "处理车辆事故", tags = "运维APP-任务中心") |
| | | @PostMapping("/maintenance-app/api/v1/task/handleVehicleAccident") |
| | | public R handleVehicleAccident(@RequestBody HandleVehicleAccidentDto dto) { |
| | | LoginOperationUser loginOperationUser = tokenService.getLoginOperationUser(); |
| | | XpOperationsUser xpOperationsUser = loginOperationUser.getXpOperationsUser(); |
| | | return xpTaskService.handleVehicleAccident(dto,xpOperationsUser); |
| | | return xpTaskService.handleVehicleAccident(dto, xpOperationsUser); |
| | | } |
| | | |
| | | /** |
| | | * 通过车辆id查询任务事故分页列表 |
| | | * |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "通过车辆id查询任务事故分页列表", tags = {"管理后台-车辆管理-运营车辆管理"}) |
| | |
| | | |
| | | /** |
| | | * 管理后台-车辆管理-运营车辆管理-删除任务/事故 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "删除删除任务/事故", tags = {"管理后台-车辆管理-运营车辆管理"}) |
| | | @DeleteMapping("/api/v1/task/delete/{id}") |
| | | public R<?> deleteTaskById(@ApiParam(name = "id", value = "任务ID") @PathVariable Long id){ |
| | | @AdminOperationLog( |
| | | businessType = AdminBusinessType.TASK_ORDER_MANAGEMENT, |
| | | operationType = AdminOperationType.DELETE, |
| | | contentExpression = "'删除任务/事故,id=' + #p0", |
| | | appendRequestData = false |
| | | ) |
| | | public R<?> deleteTaskById(@ApiParam(name = "id", value = "任务ID") @PathVariable Long id) { |
| | | xpTaskService.deleteTaskById(id); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @ApiOperation(value = "事故类型列表", response = XpErrorType.class, tags = "管理后台-车辆管理-运营车辆管理") |
| | | @GetMapping("/api/v1/task/errorTypeTreeList") |
| | | public R<List<XpErrorType>> errorTypeTreeList() { |
| | | return xpErrorTypeService.errorTypeList(); |
| | | } |
| | | |
| | | /** |
| | | * 通过车辆id查询上一次保养记录 |
| | | * |
| | | * @param vehicleId 车辆ID |
| | | */ |
| | | @GetMapping("/logan/inner/xpTask/queryInfoByVehicleId") |
| | | public R<XpTask> queryInfoByVehicleId(@RequestParam("vehicleId") Long vehicleId) { |
| | | XpTask xpTask = xpTaskService.queryInfoByVehicleId(vehicleId); |
| | | |
| | | String taskImage = xpTask.getTaskImage(); |
| | | if (StringUtils.isNotBlank(taskImage)) { |
| | | JSONArray jsonArray = JSONArray.parseArray(taskImage); |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | JSONObject jsonObject = jsonArray.getJSONObject(i); |
| | | if (Objects.isNull(jsonObject)) { |
| | | continue; |
| | | } |
| | | String downloadUrl = jsonObject.getString("url"); |
| | | ; |
| | | try { |
| | | downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true); |
| | | } catch (UnsupportedEncodingException e) { |
| | | log.error("获取图片下载地址失败", e); |
| | | } |
| | | jsonObject.put("url", downloadUrl); |
| | | } |
| | | xpTask.setTaskImage(JSONArray.toJSONString(jsonArray)); |
| | | } |
| | | return R.ok(xpTask); |
| | | } |
| | | |
| | | @ApiOperation(value = "待改派的工单分页列表", tags = {"管理后台-运维执行-任务工单-待改派工单"}) |
| | | @PostMapping("/api/v1/task/reassign/pageList") |
| | | public R<PageInfo<XpTaskVO>> reassignTaskPageList(@RequestBody TaskPageListQuery query) { |
| | | return R.ok(xpTaskService.reassignTaskPageList(query)); |
| | | } |
| | | |
| | | @ApiOperation(value = "待改派的工单导出", tags = {"管理后台-运维执行-任务工单-待改派工单"}) |
| | | @PostMapping("/api/v1/task/reassign/export") |
| | | @AdminOperationLog( |
| | | businessType = AdminBusinessType.TASK_ORDER_MANAGEMENT, |
| | | operationType = AdminOperationType.EXPORT, |
| | | content = "导出待改派工单", |
| | | appendRequestData = true |
| | | ) |
| | | public R<?> export(@RequestBody TaskPageListQuery query, HttpServletResponse response) { |
| | | List<XpTaskVO> list = xpTaskService.exportList(query); |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), XpCruiseCheckInRecordVO.class, list); |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | ServletOutputStream outputStream = null; |
| | | try { |
| | | String fileName = URLEncoder.encode("巡游打卡记录.xls", "utf-8"); |
| | | response.setHeader("Content-disposition", "attachment;filename=" + fileName); |
| | | outputStream = response.getOutputStream(); |
| | | workbook.write(outputStream); |
| | | outputStream.flush(); |
| | | } catch (IOException e) { |
| | | log.error("导出巡游打卡记录失败", e); |
| | | } finally { |
| | | try { |
| | | if (outputStream != null) { |
| | | outputStream.close(); |
| | | } |
| | | if (workbook != null) { |
| | | workbook.close(); |
| | | } |
| | | } catch (IOException e) { |
| | | log.error("关闭输出流失败", e); |
| | | } |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "可改派的运维人员列表", tags = {"管理后台-运维执行-任务工单-待改派工单"}) |
| | | @PostMapping("/api/v1/task/reassign/availableUsers") |
| | | public R<PageInfo<XpOperationsUserWithRoleVO>> availableReassignUsers(@RequestBody OptionalUsersPageListQuery query1) { |
| | | XpTask task = xpTaskService.getById(query1.getTaskId()); |
| | | // 找到中心点 |
| | | GeoJsonPoint geoJsonPoint = new GeoJsonPoint(task.getVehicleLon().doubleValue(), task.getVehicleLat().doubleValue()); |
| | | // 构造半径 |
| | | Distance distanceR = new Distance(10, Metrics.KILOMETERS); |
| | | // 画圆 |
| | | Circle circle = new Circle(geoJsonPoint, distanceR); |
| | | Query query = Query.query(new Criteria().andOperator( |
| | | Criteria.where("location").withinSphere(circle) |
| | | )); |
| | | // 增加时间查询条件:最近1分钟更新的数据 |
| | | int time = 10*60*1000; |
| | | Long oneMinuteAgo = System.currentTimeMillis() - time; |
| | | query.addCriteria(Criteria.where("updateTime").gte(oneMinuteAgo)); |
| | | |
| | | List<XpOperationsUserPositionDTO> vehiclePositions = mongoTemplate.find(query, XpOperationsUserPositionDTO.class); |
| | | if(CollUtil.isEmpty(vehiclePositions)){ |
| | | throw new ServiceException("未查询到运维人员"); |
| | | } |
| | | List<Long> data = null ; |
| | | if(StrUtil.isNotBlank(query1.getFleet())){ |
| | | // 查询车队下面面所有人员id和up求交集 |
| | | data = xpFleetClient.idsByFleetName(query1.getFleet()).getData(); |
| | | } |
| | | //vehiclePositions根据距离升序排序 |
| | | vehiclePositions.sort(Comparator.comparing(XpOperationsUserPositionDTO::getDistance)); |
| | | //获取运维人员id |
| | | List<Long> ids = new ArrayList<>(); |
| | | Map<Long, Double> disMap = new HashMap<>(); |
| | | if ( CollUtil.isNotEmpty(data) ) { |
| | | for (XpOperationsUserPositionDTO vehiclePosition : vehiclePositions) { |
| | | if(data.contains(vehiclePosition.getId())){ |
| | | ids.add(vehiclePosition.getId()); |
| | | disMap.put(vehiclePosition.getId(), vehiclePosition.getDistance()); |
| | | } |
| | | } |
| | | }else{ |
| | | for (XpOperationsUserPositionDTO vehiclePosition : vehiclePositions) { |
| | | ids.add(vehiclePosition.getId()); |
| | | disMap.put(vehiclePosition.getId(), vehiclePosition.getDistance()); |
| | | } |
| | | } |
| | | query1.setIds(ids); |
| | | query1.setOrderByField(1); |
| | | PageInfo<XpOperationsUserWithRoleVO> ret = operationUserClient.listByQueryIds(query1).getData(); |
| | | |
| | | // 设置距离,然后排序 |
| | | if (ret == null || ret.getRecords() == null || ret.getRecords().isEmpty()) { |
| | | return R.ok(); |
| | | } |
| | | if(CollUtil.isNotEmpty(ids)){ |
| | | R<List<XpFleetOperations>> findListByUserIdsR = xpFleetOperationsClient.findListByUserIds(ids); |
| | | if(findListByUserIdsR.getCode() != R.SUCCESS || findListByUserIdsR.getData().isEmpty()){ |
| | | throw new ServiceException("未查询该车队"); |
| | | } |
| | | // 将查询结果转换为 Map,key 为 userId,value 为 XpFleetOperations 对象 |
| | | Map<Long, XpFleetOperations> fleetOperationsMap = findListByUserIdsR.getData().stream() |
| | | .collect(Collectors.toMap(XpFleetOperations::getOperationsUserId, Function.identity())); |
| | | |
| | | for (XpOperationsUserWithRoleVO record : ret.getRecords()) { |
| | | if(fleetOperationsMap.containsKey(record.getId())){ |
| | | record.setFleetName(fleetOperationsMap.get(record.getId()).getFleetName()); |
| | | } |
| | | } |
| | | } |
| | | ret.getRecords().forEach(e -> e.setDis(disMap.get(e.getId()))); |
| | | // List<XpOperationsUserWithRoleVO> sorted = ret.getRecords().stream().sorted(Comparator.comparing(XpOperationsUserWithRoleVO::getDis)).collect(Collectors.toList()); |
| | | // ret.setRecords(sorted); |
| | | return R.ok(ret); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "改派详情", tags = {"管理后台-运维执行-任务工单-待改派工单"}) |
| | | @GetMapping("/api/v1/task/detail") |
| | | public R<XpTaskVO> reassignDetail(@RequestParam Long taskId) { |
| | | return R.ok(xpTaskService.detail(taskId)); |
| | | } |
| | | |
| | | @ApiOperation(value = "执行保险年检检测定时任务", tags = {"定时任务"}) |
| | | @GetMapping("/base/task/insurance/execute") |
| | | public R<?> executeInsuranceTask() { |
| | | insuranceInspectionScheduleTask.executeInsuranceInspectionTask(); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "运营后台改派工单", tags = {"管理后台-运维执行-任务工单-待改派工单"}) |
| | | @PostMapping("/api/v1/task/reassign/taskReassignment") |
| | | @AdminOperationLog( |
| | | businessType = AdminBusinessType.TASK_ORDER_MANAGEMENT, |
| | | operationType = AdminOperationType.EDIT, |
| | | contentExpression = "'运营后台改派工单,taskId=' + #p0.taskId + ',newOperationsUserId=' + #p0.newOperationsUserId", |
| | | appendRequestData = false |
| | | ) |
| | | public R<?> taskReassignment(@RequestBody TaskReassignmentVo vo){ |
| | | xpTaskService.taskReassignment(vo); |
| | | return R.ok(); |
| | | } |
| | | } |