| | |
| | | package com.xiaopeng.maintenance.controller; |
| | | |
| | | |
| | | import com.alibaba.fastjson2.JSONArray; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | 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.XpTaskHandleDetailRoutine; |
| | | import com.xiaopeng.api.model.maintenance.XpTaskRule; |
| | | import com.xiaopeng.api.model.order.XpCruiseOrder; |
| | | import com.xiaopeng.api.model.vehicleConvoy.XpVehicle; |
| | | import com.xiaopeng.api.vo.account.LoginOperationUser; |
| | | import com.xiaopeng.api.vo.automaticPilot.VehiclePosition; |
| | | import com.xiaopeng.common.core.domain.R; |
| | | import com.xiaopeng.common.core.web.page.PageInfo; |
| | | 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.vo.TaskAccidentDetailVO; |
| | | import com.xiaopeng.maintenance.model.vo.TaskChargingDetailVO; |
| | | import com.xiaopeng.maintenance.model.vo.TaskPageListVO; |
| | | import com.xiaopeng.maintenance.model.vo.TaskRoutineDetailVO; |
| | | 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.TaskCleanDetailVO; |
| | | import com.xiaopeng.maintenance.vo.TaskDetectionDetailVO; |
| | | import com.xiaopeng.maintenance.vo.VehicleListVO; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | 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.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.validation.Valid; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import com.xiaopeng.common.log.annotation.AdminOperationLog; |
| | | import com.xiaopeng.common.log.enums.AdminBusinessType; |
| | | import com.xiaopeng.common.log.enums.AdminOperationType; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | @RestController |
| | | @Slf4j |
| | | @Api(tags = "运维APP-任务中心") |
| | | @RequestMapping("/api/v1/task") |
| | | public class XpTaskController { |
| | | @Resource |
| | | private XpTaskService xpTaskService; |
| | | @Resource |
| | | private MongoTemplate mongoTemplate; |
| | | @Resource |
| | | private TokenService tokenService; |
| | | @Resource |
| | |
| | | private XpFleetOperationsClient xpFleetOperationsClient; |
| | | @Resource |
| | | private XpVehicleClient xpVehicleClient; |
| | | @ApiOperation(value = "任务中心列表", response = XpErrorType.class) |
| | | @GetMapping("/errorTypeList") |
| | | @Autowired |
| | | private InsuranceInspectionScheduleTask insuranceInspectionScheduleTask; |
| | | @Autowired |
| | | private AliOssService aliOssService; |
| | | |
| | | @Resource |
| | | private XpTaskRuleMapper xpTaskRuleMapper; |
| | | |
| | | @Resource |
| | | private AccidentTaskQuartzScheduler accidentTaskQuartzScheduler; |
| | | |
| | | @ApiOperation(value = "事故类型列表", response = XpErrorType.class, tags = "运维APP-任务中心") |
| | | @GetMapping("/api/v1/task/errorTypeList") |
| | | public R<List<XpErrorType>> errorTypeList() { |
| | | return xpErrorTypeService.errorTypeList(); |
| | | } |
| | | @ApiOperation(value = "任务中心列表", response = TaskPageListVO.class) |
| | | @PostMapping("/pageList") |
| | | |
| | | @ApiOperation(value = "任务中心列表", response = TaskPageListVO.class, tags = "运维APP-任务中心") |
| | | @PostMapping("/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 = "事故任务确认到达") |
| | | @GetMapping("/confirmArrive") |
| | | @Transactional |
| | | public R confirmArrive( Integer id) { |
| | | return xpTaskService.confirmArrive(id); |
| | | |
| | | @ApiOperation(value = "事故任务确认到达", tags = "运维APP-任务中心") |
| | | @GetMapping("/api/v1/task/confirmArrive") |
| | | public R confirmArrive(Long id) { |
| | | Long userId = tokenService.getLoginOperationUser().getXpOperationsUser().getId(); |
| | | return xpTaskService.confirmArrive(id, userId); |
| | | } |
| | | @ApiOperation(value = "查询车辆不分页列表") |
| | | @PostMapping("/listVehicle") |
| | | |
| | | @ApiOperation(value = "查询车辆不分页列表", tags = "运维APP-任务中心") |
| | | @PostMapping("/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 = "上传车辆事故") |
| | | @PostMapping("/saveVehicleAccident") |
| | | |
| | | @ApiOperation(value = "上传车辆事故", tags = "运维APP-任务中心") |
| | | @PostMapping("/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 = "车辆事故任务详情") |
| | | @GetMapping("/vehicleAccidentDetail") |
| | | public R<TaskAccidentDetailVO> vehicleAccidentDetail(Long id) { |
| | | |
| | | @ApiOperation(value = "车辆事故任务详情", tags = "运维APP-任务中心") |
| | | @GetMapping("/api/v1/task/vehicleAccidentDetail") |
| | | public R<TaskAccidentDetailVO> vehicleAccidentDetail(Long id) throws UnsupportedEncodingException { |
| | | return xpTaskService.vehicleAccidentDetail(id); |
| | | } |
| | | |
| | | @ApiOperation(value = "车辆其他常规任务详情") |
| | | @GetMapping("/vehicleRoutineDetail") |
| | | public R<TaskRoutineDetailVO> vehicleRoutineDetail(Long id) { |
| | | @ApiOperation(value = "车辆其他常规任务详情", tags = "运维APP-任务中心") |
| | | @GetMapping("/api/v1/task/vehicleRoutineDetail") |
| | | public R<TaskRoutineDetailVO> vehicleRoutineDetail(Long id) throws UnsupportedEncodingException { |
| | | return xpTaskService.vehicleRoutineDetail(id); |
| | | } |
| | | @ApiOperation(value = "上传车辆其他常规任务详情") |
| | | @PostMapping("/saveRoutineDetail") |
| | | |
| | | @ApiOperation(value = "上传车辆其他常规任务详情", tags = "运维APP-任务中心") |
| | | @PostMapping("/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 = "车辆常规充电任务详情") |
| | | @GetMapping("/chargingDetail") |
| | | |
| | | @ApiOperation(value = "车辆常规充电任务详情", tags = "运维APP-任务中心") |
| | | @GetMapping("/api/v1/task/chargingDetail") |
| | | public R<TaskChargingDetailVO> chargingDetail(Long id) { |
| | | return xpTaskService.chargingDetail(id); |
| | | } |
| | | |
| | | @ApiOperation(value = "车辆常规维修任务详情") |
| | | @GetMapping("/repairDetail") |
| | | public R<com.xiaopeng.maintenance.vo.TaskRepairDetailVO> repairDetail(Long id) { |
| | | @ApiOperation(value = "车辆常规维修任务详情", tags = "运维APP-任务中心") |
| | | @GetMapping("/api/v1/task/repairDetail") |
| | | public R<TaskRepairDetailVO> repairDetail(Long id) { |
| | | return xpTaskService.repairDetail(id); |
| | | } |
| | | @ApiOperation(value = "车辆常规整备任务详情") |
| | | @GetMapping("/preparationDetail") |
| | | public R<com.xiaopeng.maintenance.vo.TaskPreparationDetailVO> preparationDetail(Long id) { |
| | | |
| | | @ApiOperation(value = "车辆常规整备任务详情", tags = "运维APP-任务中心") |
| | | @GetMapping("/api/v1/task/preparationDetail") |
| | | public R<TaskPreparationDetailVO> preparationDetail(Long id) { |
| | | return xpTaskService.preparationDetail(id); |
| | | } |
| | | @ApiOperation(value = "车辆常规检测任务详情") |
| | | @GetMapping("/detectionDetail") |
| | | public R<com.xiaopeng.maintenance.vo.TaskDetectionDetailVO> detectionDetail(Long id) { |
| | | |
| | | @ApiOperation(value = "车辆常规检测任务详情", tags = "运维APP-任务中心") |
| | | @GetMapping("/api/v1/task/detectionDetail") |
| | | public R<TaskDetectionDetailVO> detectionDetail(Long id) { |
| | | return xpTaskService.detectionDetail(id); |
| | | } |
| | | @ApiOperation(value = "车辆常规洗车任务详情") |
| | | @GetMapping("/cleanDetail") |
| | | public R<com.xiaopeng.maintenance.vo.TaskCleanDetailVO> cleanDetail(Long id) { |
| | | |
| | | @ApiOperation(value = "车辆常规洗车任务详情", tags = "运维APP-任务中心") |
| | | @GetMapping("/api/v1/task/cleanDetail") |
| | | public R<TaskCleanDetailVO> cleanDetail(Long id) throws UnsupportedEncodingException { |
| | | return xpTaskService.cleanDetail(id); |
| | | } |
| | | @ApiOperation(value = "处理车辆事故") |
| | | @PostMapping("/handleVehicleAccident") |
| | | |
| | | @Transactional |
| | | @ShardingSphereTransactionType(TransactionType.BASE) |
| | | @ApiOperation(value = "处理车辆事故", tags = "运维APP-任务中心") |
| | | @PostMapping("/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 = {"管理后台-车辆管理-运营车辆管理"}) |
| | | @PostMapping("/api/v1/vehicle/queryTaskByVehicleId") |
| | | public R<PageInfo<XpTaskRecordVO>> queryTaskByVehicleId(@Valid @RequestBody XpTaskRecordPageQuery query) { |
| | | return R.ok(xpTaskService.queryTaskByVehicleId(query)); |
| | | } |
| | | |
| | | /** |
| | | * 管理后台-车辆管理-运营车辆管理-删除任务/事故 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "删除删除任务/事故", tags = {"管理后台-车辆管理-运营车辆管理"}) |
| | | @DeleteMapping("/api/v1/task/delete/{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("/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 = {"定时任务"}) |
| | | @GetMapping("/base/task/insurance/execute") |
| | | public R<?> executeInsuranceTask() { |
| | | insuranceInspectionScheduleTask.executeInsuranceInspectionTask(); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | } |