whyclxw
2025-03-29 b2304cfc3342211dfd161de427879fa813a22a44
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package com.whyc.controller;
import com.whyc.dto.Response;
import com.whyc.service.AnaysiService;
import com.whyc.util.AnalysisUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
 
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.ParseException;
 
 
@RequestMapping("anaysis")
@RestController
@Api(tags = "预估10小时数据")
public class AnaysisController {
    @Autowired
    private AnaysiService service;
 
    @ApiOperation("生成预估数据")
    @GetMapping("createAnaysisXls")
    public Response createAnaysisXls(@RequestParam int battGroupId, @RequestParam int testRecordCount){
        String voltagePredictExePath=service.createAnaysisXls(battGroupId,testRecordCount);
        return new Response().setII(1,true,voltagePredictExePath,"生成预估数据");
    }
 
    @ApiOperation("查询预估数据")
    @GetMapping("getAnaysisXls")
    public Response getAnaysisXls(@RequestParam int battGroupId, @RequestParam int testRecordCount){
        return service.getAnaysisXls(battGroupId,testRecordCount);
    }
 
    @ApiOperation("解析xls文件到放电数据中")
    @PostMapping("anaysisXlsToTdata")
    public Response anaysisXlsToTdata(@RequestParam int battGroupId,@RequestParam MultipartFile multipartFile) throws IOException, InvalidFormatException, ParseException {
        Response<Object> response = new Response<>();
        String name=multipartFile.getOriginalFilename();
        assert name != null;
        if(!name.substring(name.length()-4).equals(".xls") && !name.substring(name.length()-5).equals(".xlsx")){
            response.set(1,false,"文件解析错误:上传格式非excel格式");
        }else{
            response =  service.anaysisXlsToTdata(battGroupId,multipartFile.getInputStream());
        }
        return response;
    }
 
    @ApiOperation("预估一个2小时后面的数据")
    @GetMapping("get2To10Data")
    public Response get2To10Data(@RequestParam int battGroupId, @RequestParam int testRecordCount1, @RequestParam int testRecordCount2){
        return service.get2To10Data(battGroupId,testRecordCount1,testRecordCount2);
    }
}