lxw
2022-09-20 52e7ec8afeb53727e4fde72fbade5e5ef8addff8
删除台站下指定文件
8个文件已修改
61 ■■■■■ 已修改文件
src/main/java/com/whyc/controller/StationInfoController.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mapper/BattGroupDataMapper.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mapper/FileInfoMapper.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mapper/FileParamMapper.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/StationInfoService.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/BattgroupDataMapper.xml 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/FileInfoMapper.xml 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/FileParamMapper.xml 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/controller/StationInfoController.java
@@ -50,4 +50,10 @@
    public Response addFileInStation(@RequestParam String stationName,@RequestParam String FilePath){
        return service.addFileInStation(stationName,FilePath);
    }
    @ApiOperation(value = "移除台站下文件(单个文件)")
    @GetMapping("delFileFromStation")
    public Response delFileFromStation(@RequestParam String stationName,@RequestParam(required = false) String FilePath){
        return service.delFileFromStation(stationName,FilePath);
    }
}
src/main/java/com/whyc/mapper/BattGroupDataMapper.java
@@ -8,4 +8,6 @@
    List<BattgroupData> getListWithTestTime(int battGroupId);
    //删除fileid对应的数据(stationId,fileId)
    int deleteDataAndInfo(int stationId, int fileId);
}
src/main/java/com/whyc/mapper/FileInfoMapper.java
@@ -6,4 +6,10 @@
    //查询出最大文件id
    int selectMaxId();
    //查出文件对应的文件id
    int selectFileId(int stationId, String filePath);
    //删除机房下文件信息(stationId,fileId)
    int deleteFileInStation(int stationId, int fileId);
}
src/main/java/com/whyc/mapper/FileParamMapper.java
@@ -10,4 +10,6 @@
    List<Integer> getMonVolStd();
    //按照筛选条件查询数据库信息
    List<FileParam> getDataByCondition(Date testTime1, Date testTime2, int battVol);
    //删除fileid对应的参数
    int deleteParamByFileId(int fileId);
}
src/main/java/com/whyc/service/StationInfoService.java
@@ -1,5 +1,6 @@
package com.whyc.service;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.whyc.dto.FileOpreate;
@@ -212,6 +213,7 @@
        return new Response().set(1,flag>0,"修改操作");
    }
    //删除台站
    @Transactional
    public Response deleteStation(String stationName1, String stationName2, String stationName3) {
        String stationName="";
        UpdateWrapper wrapper=new UpdateWrapper();
@@ -225,7 +227,33 @@
            stationName=stationName+"-"+stationName3;
        }
        wrapper.eq("station_name",stationName);
        //先删除该基站挂载的所有文件
        int flag=mapper.delete(wrapper);
        return new Response().set(1,flag>0,"删除操作");
    }
    //移除台站下文件(单个文件)
    @Transactional
    public Response delFileFromStation(String stationName, String filePath) {
        //1.先查出机房的id
        int stationId=mapper.selectIdByName(stationName);
        if(stationId==0){
            return new Response().set(1,false,"机房不存在");
        }else{
            //2.查出文件对应的文件id
            int fileId=infoMapper.selectFileId(stationId,filePath);
            if(fileId==0){
                return new Response().set(1,false,"文件不存在");
            }else{
                //3.删除fileid对应的数据(stationId,fileId)
                dataMapper.deleteDataAndInfo(stationId,fileId);
                //4.删除fileid对应的参数
                paramMapper.deleteParamByFileId(fileId);
                //5.删除机房下文件信息(stationId,fileId)
                infoMapper.deleteFileInStation(stationId,fileId);
                return  new Response().set(1,true,"删除成功");
            }
        }
    }
}
src/main/resources/mapper/BattgroupDataMapper.xml
@@ -1,6 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.whyc.mapper.BattGroupDataMapper">
    <delete id="deleteDataAndInfo">
        DELETE o,c
        FROM tb_battgroup_data o
        LEFT JOIN tb_battgroup_info c ON o.battGroup_id = c.battGroup_id
        WHERE c.station_id=#{stationId} and c.file_id=#{fileId}
    </delete>
    <select id="getListWithTestTime" resultType="com.whyc.pojo.BattgroupData">
        SELECT data.*,info.test_time FROM db_res_meter.tb_battgroup_data data,db_res_meter.tb_battgroup_info info
src/main/resources/mapper/FileInfoMapper.xml
@@ -1,9 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.whyc.mapper.FileInfoMapper">
    <delete id="deleteFileInStation">
        delete from tb_file_info where  station_id=#{stationId} and file_id=#{fileId}
    </delete>
    <select id="selectMaxId" resultType="java.lang.Integer">
        select ifnull(max(file_id),"10001") from db_res_meter.tb_file_info limit 1
    </select>
    <select id="selectFileId" resultType="java.lang.Integer">
        select ifnull(max(file_id),0) from db_res_meter.tb_file_info
        where  station_id=#{stationId} and file_url=#{filePath}
    </select>
</mapper>
src/main/resources/mapper/FileParamMapper.xml
@@ -1,6 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.whyc.mapper.FileParamMapper">
    <delete id="deleteParamByFileId">
        delete from tb_file_param where  file_id=#{fileId}
    </delete>
    <select id="getMonVolStd" resultType="Integer">