| | |
| | | package com.xiaopeng.maintenance.controller; |
| | | |
| | | |
| | | import cn.afterturn.easypoi.excel.ExcelExportUtil; |
| | | import cn.afterturn.easypoi.excel.entity.ExportParams; |
| | | import com.xiaopeng.api.feignClient.vehicleConvoy.XpFleetOperationsClient; |
| | | import com.xiaopeng.api.feignClient.vehicleConvoy.XpVehicleClient; |
| | | import com.xiaopeng.api.model.account.SysUser; |
| | | import com.xiaopeng.api.model.account.XpOperationsUser; |
| | | import com.xiaopeng.api.model.maintenance.XpErrorType; |
| | | import com.xiaopeng.api.model.operation.XpWhitelist; |
| | | import com.xiaopeng.api.model.operation.XpWhitelistOperlog; |
| | | import com.xiaopeng.api.model.vehicleConvoy.XpVehicle; |
| | | import com.xiaopeng.api.vo.account.LoginOperationUser; |
| | | import com.xiaopeng.common.core.domain.R; |
| | | import com.xiaopeng.common.core.utils.WebUtils; |
| | | 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.maintenance.dto.HandleVehicleAccidentDto; |
| | | import com.xiaopeng.maintenance.dto.SaveErrorTaskDto; |
| | | import com.xiaopeng.maintenance.dto.SaveRoutineDetailDto; |
| | | import com.xiaopeng.maintenance.dto.SaveVehicleAccidentDto; |
| | | import com.xiaopeng.maintenance.exportExcel.XpTaskExportExcel; |
| | | import com.xiaopeng.maintenance.model.query.TaskManagementPageListQuery; |
| | | import com.xiaopeng.maintenance.model.query.TaskPageListQuery; |
| | | import com.xiaopeng.maintenance.model.query.XpTaskRecordPageQuery; |
| | |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | 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.io.IOException; |
| | | import java.net.URLEncoder; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * 运维APP 任务中心 |
| | | * 管理后台 任务工单 |
| | | * </p> |
| | | * |
| | | * @author mitao |
| | |
| | | public R<List<XpErrorType>> errorTypeList() { |
| | | return xpErrorTypeService.errorTypeList(); |
| | | } |
| | | @ApiOperation(value = "任务中心列表", response = TaskPageListVO.class) |
| | | @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) { |
| | | List<TaskManagementPageListVO> exportList = xpTaskService.exportList(query); |
| | | List<XpTaskExportExcel> taskExportExcels = new ArrayList<>(); |
| | | Integer num = 1; |
| | | for (TaskManagementPageListVO task : exportList) { |
| | | XpTaskExportExcel xpTaskExportExcel = new XpTaskExportExcel(); |
| | | xpTaskExportExcel.setPlateNumber(task.getPlateNumber()); |
| | | xpTaskExportExcel.setTaskCategory(task.getTaskCategory()); |
| | | xpTaskExportExcel.setTaskTypeName(task.getTaskTypeName()); |
| | | xpTaskExportExcel.setTaskUrgencyLevel(task.getTaskUrgencyLevel()); |
| | | xpTaskExportExcel.setTaskDescription(task.getTaskDescription()); |
| | | xpTaskExportExcel.setHandleUserName(task.getHandleUserName()); |
| | | xpTaskExportExcel.setNumber(num); |
| | | xpTaskExportExcel.setStatus(task.getStatus()); |
| | | LocalDateTime createTime = task.getCreateTime(); |
| | | // 将LocalDateTime转化为yyyy-MM-dd HH:mm:ss格式字符串 |
| | | xpTaskExportExcel.setCreateTime(createTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
| | | taskExportExcels.add(xpTaskExportExcel); |
| | | num++; |
| | | } |
| | | //1.获取excel模板 |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), XpTaskExportExcel.class, taskExportExcels); |
| | | HttpServletResponse response = WebUtils.response(); |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | ServletOutputStream outputStream = null; |
| | | try { |
| | | String fileName = URLEncoder.encode("任务工单列表.xls", "utf-8"); |
| | | response.setHeader("Content-dispodition", "attachment;filename=" + fileName); |
| | | outputStream = response.getOutputStream(); |
| | | workbook.write(outputStream); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | outputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | } |
| | | /** |
| | | * 管理后台-车辆管理-运营车辆管理-删除任务/事故 |
| | |
| | | } |
| | | @ApiOperation(value = "查询车辆不分页列表") |
| | | @PostMapping(" /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 查询车辆列表 获取经纬度 |
| | | List<XpVehicle> data = xpVehicleClient.listByIds(vehicleIds).getData(); |
| | | 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()); |
| | | vehicleListVO.setVehicleCode(xpVehicle.getVehicleCode()); |
| | | vehicleListVO.setVehicleColor(xpVehicle.getVehicleColor()); |
| | | vehicleListVO.setPlateNumber(xpVehicle.getPlateNumber()); |
| | | vehicleListVO.setOperatingStatus(xpVehicle.getOperatingStatus()); |
| | | vehicleListVOS.add(vehicleListVO); |
| | | } |
| | | return R.ok(vehicleListVOS); |
| | | |
| | | } |
| | | public R<List<XpVehicle>> listVehicle() { |
| | | List<XpVehicle> vehicles = xpVehicleClient.listVehicle().getData(); |
| | | if (vehicles == null){ |
| | | return R.ok(new ArrayList<>()); |
| | | } |
| | | |
| | | return R.ok(new ArrayList<>()); |
| | | } |
| | | @ApiOperation(value = "上传车辆事故", tags = "运维APP-任务中心") |
| | | @PostMapping(" /saveVehicleAccident") |
| | | public R saveVehicleAccident(@RequestBody SaveVehicleAccidentDto dto) { |
| | | LoginOperationUser loginOperationUser = tokenService.getLoginOperationUser(); |
| | | XpOperationsUser xpOperationsUser = loginOperationUser.getXpOperationsUser(); |
| | | xpTaskService.saveVehicleAccident(dto, xpOperationsUser); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "车辆其他常规任务详情", tags = "运维APP-任务中心") |
| | | @GetMapping(" /vehicleRoutineDetail") |
| | | public R<TaskRoutineDetailVO> vehicleRoutineDetail(Long id) { |
| | | return xpTaskService.vehicleRoutineDetail(id); |
| | | } |
| | | @ApiOperation(value = "上传车辆其他常规任务详情", tags = "运维APP-任务中心") |
| | | @PostMapping(" /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(" /chargingDetail") |
| | | public R<TaskChargingDetailVO> chargingDetail(Long id) { |
| | | return xpTaskService.chargingDetail(id); |
| | | } |
| | | |
| | | @ApiOperation(value = "车辆常规维修任务详情", tags = "运维APP-任务中心") |
| | | @GetMapping(" /repairDetail") |
| | | public R<com.xiaopeng.maintenance.vo.TaskRepairDetailVO> repairDetail(Long id) { |
| | | return xpTaskService.repairDetail(id); |
| | | } |
| | | @ApiOperation(value = "车辆常规整备任务详情", tags = "运维APP-任务中心") |
| | | @GetMapping(" /preparationDetail") |
| | | public R<com.xiaopeng.maintenance.vo.TaskPreparationDetailVO> preparationDetail(Long id) { |
| | | return xpTaskService.preparationDetail(id); |
| | | } |
| | | @ApiOperation(value = "车辆常规检测任务详情", tags = "运维APP-任务中心") |
| | | @GetMapping(" /detectionDetail") |
| | | public R<com.xiaopeng.maintenance.vo.TaskDetectionDetailVO> detectionDetail(Long id) { |
| | | return xpTaskService.detectionDetail(id); |
| | | } |
| | | @ApiOperation(value = "车辆常规洗车任务详情", tags = "运维APP-任务中心") |
| | | @GetMapping(" /cleanDetail") |
| | | public R<com.xiaopeng.maintenance.vo.TaskCleanDetailVO> cleanDetail(Long id) { |
| | | return xpTaskService.cleanDetail(id); |
| | | } |
| | | @ApiOperation(value = "处理车辆事故", tags = "运维APP-任务中心") |
| | | @PostMapping(" /handleVehicleAccident") |
| | | @Transactional |
| | | public R handleVehicleAccident(@RequestBody HandleVehicleAccidentDto dto) { |
| | | LoginOperationUser loginOperationUser = tokenService.getLoginOperationUser(); |
| | | XpOperationsUser xpOperationsUser = loginOperationUser.getXpOperationsUser(); |
| | | return xpTaskService.handleVehicleAccident(dto,xpOperationsUser); |
| | | return R.ok(vehicles); |
| | | } |
| | | |
| | | /** |