luodangjia
2024-10-11 bd97f8c5cd9be78abfaaab295319bd7ceef98f11
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TChargingGunController.java
@@ -3,6 +3,7 @@
import cn.hutool.core.img.ImgUtil;
import cn.hutool.core.io.FileUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.chargingPile.api.dto.GetSiteListDTO;
import com.ruoyi.chargingPile.api.dto.TChargingGunDTO;
@@ -11,6 +12,7 @@
import com.ruoyi.chargingPile.api.model.TChargingPile;
import com.ruoyi.chargingPile.api.model.TFaultMessage;
import com.ruoyi.chargingPile.api.query.TChargingGunQuery;
import com.ruoyi.chargingPile.api.vo.GetChargingGunByCode;
import com.ruoyi.chargingPile.api.vo.GunStatusStatisticsVO;
import com.ruoyi.chargingPile.api.vo.SiteNameVO;
import com.ruoyi.chargingPile.api.vo.TChargingGunVO;
@@ -155,7 +157,7 @@
    public void downloadQRCode(@PathVariable Integer id, HttpServletResponse response){
        try {
            TChargingGun chargingGun = chargingGunService.getById(id);
            TChargingPile chargingPile = chargingPileService.getById(chargingGun.getId());
            TChargingPile chargingPile = chargingPileService.getById(chargingGun.getChargingPileId());
            String code = chargingPile.getCode() + chargingGun.getCode();
            String fileName = URLEncoder.encode(code, "UTF-8") + ".jpg";
            response.setContentType("application/force-download");
@@ -175,15 +177,15 @@
            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();
            }
//            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();
        }
@@ -254,11 +256,14 @@
     * @param code
     * @return
     */
    @PostMapping("/getChargingGunByCode/{code}")
    public R<TChargingGun> getChargingGunByCode(@PathVariable("code") String code){
    @PostMapping("/getChargingGunByCode")
    public R<TChargingGun> getChargingGunByCode(@RequestBody GetChargingGunByCode code){
        TChargingPile chargingPile = chargingPileService.getOne(new LambdaQueryWrapper<TChargingPile>().eq(TChargingPile::getCode, code.getCharging_pile_code()).eq(TChargingPile::getDelFlag, 0));
        return R.ok(chargingGunService.getOne(Wrappers.lambdaQuery(TChargingGun.class)
                .eq(TChargingGun::getCode, code)
                .last("LIMIT 1")));
                        .eq(TChargingGun::getChargingPileId, chargingPile.getId())
                        .eq(TChargingGun::getCode, code.getCharging_gun_code())
                        .eq(TChargingGun::getDelFlag, 0)
                        .last("LIMIT 1")));
    }
    /**
     * 根据枪编号获取充电枪