| | |
| | | |
| | | import cn.afterturn.easypoi.excel.ExcelExportUtil; |
| | | import cn.afterturn.easypoi.excel.entity.ExportParams; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.xiaopeng.api.feignClient.account.XpOperationUserClient; |
| | | import com.xiaopeng.api.feignClient.vehicleConvoy.XpFleetOperationsClient; |
| | | import com.xiaopeng.api.feignClient.vehicleConvoy.XpVehicleClient; |
| | |
| | | import com.xiaopeng.common.core.utils.ip.IpUtils; |
| | | 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.SaveErrorTaskDto; |
| | | import com.xiaopeng.maintenance.dto.SaveRoutineDetailDto; |
| | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.validation.Valid; |
| | | import java.io.IOException; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.net.URLEncoder; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | |
| | | @Resource |
| | | private XpOperationUserClient operationUserClient; |
| | | @Resource |
| | | private XpFleetOperationsClient xpFleetOperationsClient; |
| | | private AliOssService aliOssService; |
| | | @Resource |
| | | private XpVehicleClient xpVehicleClient; |
| | | |
| | | @ApiOperation(value = "事故类型列表", response = XpErrorType.class) |
| | | @GetMapping("/errorTypeList") |
| | | public R<List<XpErrorType>> errorTypeList() { |
| | | return xpErrorTypeService.errorTypeList(); |
| | | } |
| | | |
| | | @ApiOperation(value = "任务中心列表", response = TaskManagementPageListVO.class) |
| | | @PostMapping("/pageList") |
| | | public R<PageInfo<TaskManagementPageListVO>> pageListManagement(@RequestBody TaskManagementPageListQuery query) { |
| | | PageInfo<TaskManagementPageListVO> pageList = xpTaskService.pageListManagement(query); |
| | | return R.ok(pageList); |
| | | } |
| | | |
| | | @ApiOperation(value = "任务工单导出") |
| | | @PostMapping(value = "/exportExcel") |
| | | public void exportExcel(@RequestBody TaskManagementPageListQuery query) { |
| | |
| | | xpTaskExportExcel.setTaskTypeName(task.getTaskTypeName()); |
| | | xpTaskExportExcel.setTaskUrgencyLevel(task.getTaskUrgencyLevel()); |
| | | xpTaskExportExcel.setTaskDescription(task.getTaskDescription()); |
| | | if (StringUtils.hasLength(task.getHandleUserId())){ |
| | | if (StringUtils.hasLength(task.getHandleUserId())) { |
| | | String[] split = task.getHandleUserId().split(","); |
| | | |
| | | List<XpOperationsUser> users = operationUserClient.listByIds(Arrays.stream(split).map(Long::parseLong).collect(Collectors.toList())).getData(); |
| | | if (users!=null){ |
| | | if (users != null) { |
| | | StringBuilder handleUserName = new StringBuilder(); |
| | | for (XpOperationsUser user : users) { |
| | | handleUserName.append(user.getNickName()).append(";"); |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 管理后台-车辆管理-运营车辆管理-删除任务/事故 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "删除任务/事故") |
| | | @DeleteMapping("/deleteTaskById") |
| | | public R<?> deleteTaskById(@ApiParam(name = "id", value = "任务ID")Long id){ |
| | | public R<?> deleteTaskById(@ApiParam(name = "id", value = "任务ID") Long id) { |
| | | xpTaskService.deleteTaskById(id); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @ApiOperation(value = "任务分配") |
| | | @GetMapping("/assigneeTask") |
| | | public R assigneeTask(@ApiParam(name = "id", value = "任务ID") Long id, @ApiParam(name = "handlerUserId", value = "处理人id")Long handlerUserId) { |
| | | public R assigneeTask(@ApiParam(name = "id", value = "任务ID") Long id, @ApiParam(name = "handlerUserId", value = "处理人id") Long handlerUserId) { |
| | | Long assigneeUserId = tokenService.getLoginUser().getSysUser().getId(); |
| | | return xpTaskService.assigneeTask(id, handlerUserId,assigneeUserId); |
| | | return xpTaskService.assigneeTask(id, handlerUserId, assigneeUserId); |
| | | } |
| | | |
| | | @ApiOperation(value = "创建任务事故") |
| | | @PostMapping("/saveTask") |
| | | public R saveTask(@RequestBody SaveErrorTaskDto dto) { |
| | |
| | | xpTaskService.saveTask(dto, reportUserId); |
| | | return R.ok(); |
| | | } |
| | | @ApiOperation(value = "异常情况上传车辆事故") |
| | | @PostMapping("/inner/v1/task/saveVehicleAccidentError") |
| | | public R saveVehicleAccidentError(@RequestParam Long vehicleId) { |
| | | |
| | | xpTaskService.saveVehicleAccidentError(vehicleId); |
| | | return R.ok(); |
| | | } |
| | | @ApiOperation(value = "任务详情") |
| | | @GetMapping("/taskDetail") |
| | | public R<TaskManagementDetailVO> taskDetail(Long id) { |
| | | public R<TaskManagementDetailVO> taskDetail(Long id) throws UnsupportedEncodingException { |
| | | return xpTaskService.taskDetail(id); |
| | | } |
| | | |
| | | @ApiOperation(value = "查询车辆不分页列表") |
| | | @PostMapping("/listVehicle") |
| | | public R<List<XpVehicle>> listVehicle() { |
| | | public R<List<XpVehicle>> listVehicle() throws UnsupportedEncodingException { |
| | | List<XpVehicle> vehicles = xpVehicleClient.listVehicle().getData(); |
| | | if (vehicles == null){ |
| | | if (vehicles == null) { |
| | | return R.ok(new ArrayList<>()); |
| | | } |
| | | for (XpVehicle vehicle : vehicles) { |
| | | String vehiclePictures = vehicle.getVehiclePictures(); |
| | | if (org.apache.commons.lang3.StringUtils.isNotBlank(vehiclePictures)) { |
| | | JSONObject jsonObject = JSONObject.parseObject(vehiclePictures); |
| | | //1 |
| | | 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); |
| | | vehicle.setVehiclePictures(jsonObject.toJSONString()); |
| | | } |
| | | } |
| | | return R.ok(vehicles); |
| | | } |
| | | |
| | | /** |
| | | * 通过车辆id查询任务事故分页列表 |
| | | * |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "通过车辆id查询任务事故分页列表", tags = {"管理后台-车辆管理-运营车辆管理"}) |