lxw
2022-09-13 dad6910a94fae66dc0818e7d404874a92d1f18d2
台站管理
1个文件已添加
5个文件已修改
51 ■■■■■ 已修改文件
src/main/java/com/whyc/controller/StationInfoController.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mapper/FileInfoMapper.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mapper/StationInfoMapper.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/StationInfoService.java 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/FileInfoMapper.xml 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/StationInfoMapper.xml 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/controller/StationInfoController.java
@@ -25,4 +25,9 @@
                              ,@RequestParam(required = false) String stationName3){
        return service.addStation(stationName1,stationName2,stationName3);
    }
    @ApiOperation(value = "台站下添加文件")
    public Response addFileInStation(@RequestParam String stationName,@RequestParam String FilePath){
        return service.addFileInStation(stationName,FilePath);
    }
}
src/main/java/com/whyc/mapper/FileInfoMapper.java
@@ -3,4 +3,7 @@
import com.whyc.pojo.FileInfo;
public interface FileInfoMapper extends CustomMapper<FileInfo>{
    //查询出最大文件id
    int selectMaxId();
}
src/main/java/com/whyc/mapper/StationInfoMapper.java
@@ -3,4 +3,6 @@
import com.whyc.pojo.StationInfo;
public interface StationInfoMapper extends CustomMapper<StationInfo>{
    //查询出最大的台站id
    int selectMaxId();
}
src/main/java/com/whyc/service/StationInfoService.java
@@ -1,16 +1,24 @@
package com.whyc.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.whyc.dto.Response;
import com.whyc.mapper.FileInfoMapper;
import com.whyc.mapper.StationInfoMapper;
import com.whyc.pojo.StationInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.io.File;
@Service
public class StationInfoService {
    @Autowired(required = false)
    private StationInfoMapper mapper;
    @Autowired(required = false)
    private FileInfoMapper infoMapper;
    //添加台站
    public Response addStation(String stationName1, String stationName2, String stationName3) {
        String stationName="";
@@ -48,4 +56,25 @@
        }
        return new Response().set(1,bl,msg);
    }
    //台站下添加文件
    @Transactional
    public Response addFileInStation(String stationName,String filePath) {
        File file=new File(filePath);
        //1.查询出最大的台站id和最大文件id
        int stationIdMax=mapper.selectMaxId();
        int fileIdMax=infoMapper.selectMaxId();
        if(file.exists()){
            //2.给台站赋予stationId
            UpdateWrapper uwrapper=new UpdateWrapper();
            uwrapper.set("station_id",stationIdMax+1);
            mapper.update(null,uwrapper);
            if(file.isFile()){
                //3.解析文件
            }else{
            }
        }
        return new Response().set(1);
    }
}
src/main/resources/mapper/FileInfoMapper.xml
New file
@@ -0,0 +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.FileInfoMapper">
    <select id="selectMaxId" resultType="java.lang.Integer">
        select max(file_id) from db_res_meter.tb_station_info limit 1
    </select>
</mapper>
src/main/resources/mapper/StationInfoMapper.xml
@@ -3,4 +3,7 @@
<mapper namespace="com.whyc.mapper.StationInfoMapper">
    <select id="selectMaxId" resultType="java.lang.Integer">
        select max(station_id) from db_res_meter.tb_station_info limit 1
    </select>
</mapper>