lxw
2022-09-20 c98b2e32e869b6ad58330a1d43d5984e68763ea6
删除台站
4个文件已修改
25 ■■■■ 已修改文件
src/main/java/com/whyc/mapper/FileInfoMapper.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mapper/StationInfoMapper.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/StationInfoService.java 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/FileInfoMapper.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mapper/FileInfoMapper.java
@@ -10,7 +10,7 @@
    int selectMaxId();
    //查出文件对应的文件id
    int selectFileId(int stationId, String filePath);
    Integer selectFileId(int stationId, String filePath);
    //删除机房下文件信息(stationId,fileId)
    int deleteFileInStation(int stationId, int fileId);
src/main/java/com/whyc/mapper/StationInfoMapper.java
@@ -4,7 +4,7 @@
public interface StationInfoMapper extends CustomMapper<StationInfo>{
    //查询出最大的台站id
    int selectMaxId();
    Integer selectMaxId();
    //根据机房名称当前机房的机房id
    int selectIdByName(String stationName);
    Integer selectIdByName(String stationName);
}
src/main/java/com/whyc/service/StationInfoService.java
@@ -1,5 +1,6 @@
package com.whyc.service;
import com.alibaba.druid.sql.visitor.functions.Isnull;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
@@ -126,14 +127,14 @@
    //4.将单文件的数据存入数据库
    private FileInfo insertFileInDataBase(String stationName,int stationIdMax,int fileIdMax, FileInfo fileInfo) {
        int count=0;
        int stationId=0;
        Integer stationId=0;
        //查询最大的电池组号
        int battGroupId=groupInfoMapper.selectMaxId();
        if(fileInfo!=null){
            //查询站点的机房是否存在stationId
            QueryWrapper wrapper=new QueryWrapper();
            stationId=mapper.selectIdByName(stationName);
            if(stationId!=0){
            if(stationId!=null||stationId!=0){
                fileInfo.setStationId(String.valueOf(stationId));
            }else{
                fileInfo.setStationId(String.valueOf(stationIdMax+1));
@@ -228,8 +229,8 @@
        }
        wrapper.eq("station_name",stationName);
        //1.先查出机房的id
        int stationId=mapper.selectIdByName(stationName);
        if(stationId==0){
        Integer stationId=mapper.selectIdByName(stationName);
        if(stationId==null||stationId==0){
            return new Response().set(1,false,"机房不存在");
        }else {
            //3.删除所有文件数据
@@ -245,13 +246,13 @@
    @Transactional
    public Response delFileFromStation(String stationName, String filePath) {
        //1.先查出机房的id
        int stationId=mapper.selectIdByName(stationName);
        if(stationId==0){
        Integer stationId=mapper.selectIdByName(stationName);
        if(stationId==null||stationId==0){
            return new Response().set(1,false,"机房不存在");
        }else{
            //2.查出文件对应的文件id
            int fileId=infoMapper.selectFileId(stationId,filePath);
            if(fileId==0){
            Integer fileId=infoMapper.selectFileId(stationId,filePath);
            if(fileId==null||fileId==0){
                return new Response().set(1,false,"文件不存在");
            }else{
                //3.删除fileid对应的数据(stationId,fileId)
src/main/resources/mapper/FileInfoMapper.xml
@@ -9,7 +9,7 @@
        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
        select ifnull(file_id,0) from db_res_meter.tb_file_info
        where  station_id=#{stationId} and file_url=#{filePath}
    </select>
    <select id="selectListFiles" resultType="java.lang.Integer">