| | |
| | | package com.xiaopeng.maintenance.controller; |
| | | |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.xiaopeng.api.feignClient.account.XpOperationUserClient; |
| | |
| | | import com.xiaopeng.maintenance.service.XpTaskService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | 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.web.bind.annotation.*; |
| | | |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | */ |
| | | @ApiOperation(value = "车辆运维-运维记录-清洁记录详情", tags = {"运维APP-车辆管理"}) |
| | | @GetMapping("/api/v1/vehicleClean/cleanDetail") |
| | | public R<XpVehicleCleanVO> cleanDetail(@RequestParam Long id) { |
| | | public R<XpVehicleCleanVO> cleanDetail(@RequestParam Long id) throws UnsupportedEncodingException { |
| | | XpVehicleCleanVO xpVehicleCleanVO = xpVehicleCleanService.cleanDetail(id); |
| | | String vehiclePictures = xpVehicleCleanVO.getVehiclePictures(); |
| | | if (vehiclePictures != null && !vehiclePictures.isEmpty()) { |
| | | JSONObject jsonObject = JSONObject.parseObject(vehiclePictures); |
| | | String downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true); |
| | | xpVehicleCleanVO.setVehiclePictures(downloadUrl); |
| | | } |
| | | |
| | | |
| | | |
| | | String taskImage = xpVehicleCleanVO.getTaskImage(); |
| | | if (StringUtils.isNotBlank(taskImage)) { |
| | | JSONArray jsonArray = JSONArray.parseArray(taskImage); |
| | | ArrayList<String> list = new ArrayList<>(jsonArray.size()); |
| | | for (Object o : jsonArray) { |
| | | JSONObject jsonObject = JSONObject.parseObject(o.toString()); |
| | | String downloadUrl = null; |
| | | try { |
| | | downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true); |
| | | } catch (UnsupportedEncodingException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | list.add(downloadUrl); |
| | | } |
| | | xpVehicleCleanVO.setTaskImage(String.join(",", list)); |
| | | } |
| | | |
| | | |
| | | return R.ok(xpVehicleCleanVO); |
| | | } |
| | | |
| | |
| | | |
| | | for (XpVehicleClean record : records) { |
| | | String taskImage = record.getTaskImage(); |
| | | if(taskImage!=null){ |
| | | JSONObject jsonObject = JSONObject.parseObject(taskImage); |
| | | String downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true); |
| | | record.setTaskImage(downloadUrl); |
| | | if (StringUtils.isNotBlank(taskImage)) { |
| | | JSONArray jsonArray = JSONArray.parseArray(taskImage); |
| | | ArrayList<String> list = new ArrayList<>(jsonArray.size()); |
| | | for (Object o : jsonArray) { |
| | | JSONObject jsonObject = JSONObject.parseObject(o.toString()); |
| | | String downloadUrl = null; |
| | | try { |
| | | downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true); |
| | | } catch (UnsupportedEncodingException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | list.add(downloadUrl); |
| | | } |
| | | record.setTaskImage(String.join(",", list)); |
| | | } |
| | | data.stream().filter(xpOperationsUser -> xpOperationsUser.getId().equals(record.getOperationsUserId())).findFirst().ifPresent(xpOperationsUser -> record.setCreateBy(xpOperationsUser.getNickName())); |
| | | } |