| | |
| | | import javax.servlet.ServletOutputStream; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.awt.image.BufferedImage; |
| | | import java.io.BufferedReader; |
| | | import java.io.FileInputStream; |
| | | import java.io.FileReader; |
| | | import java.io.PrintWriter; |
| | | import java.io.*; |
| | | import java.net.URLEncoder; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | |
| | | @ApiOperation(tags = {"后台-充电枪"},value = "结束充电") |
| | | @PutMapping(value = "/stopCharging") |
| | | public AjaxResult<String> stopCharging(@RequestParam("id") String id) { |
| | | // 根据充电枪id 查询最新的一笔订单 |
| | | String data = chargingOrderClient.queryOrderByGunId(id).getData(); |
| | | // 硬件 结束充电 |
| | | chargingOrderClient.stopCharging(id); |
| | | chargingOrderClient.stopCharging(data); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | |
| | | response.setContentType("application/force-download"); |
| | | response.addHeader("Content-Disposition", "attachment;fileName=" + fileName); |
| | | String url = "https://mxcd.zhinenganguan.com?No=" + code; |
| | | String filePath = fileUploadConfig.getLocation(); |
| | | String filePath = fileUploadConfig.getLocation() + fileName; |
| | | QRCodeUtils.encode(url, filePath); |
| | | FileInputStream inputStream = new FileInputStream(filePath); |
| | | ServletOutputStream out = response.getOutputStream(); |
| | |
| | | out.flush(); |
| | | out.close(); |
| | | inputStream.close(); |
| | | |
| | | //清楚服务器上的文件 |
| | | Process process = null; |
| | | try { |
| | | process = Runtime.getRuntime().exec("sudo rm -rf " + filePath); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | if (process != null) { |
| | | process.destroy(); |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |