|
|
|
@ -1,21 +1,24 @@
|
|
|
|
|
package com.xydl.cac.controller;
|
|
|
|
|
|
|
|
|
|
import com.xydl.cac.entity.IcdFile;
|
|
|
|
|
import com.xydl.cac.exception.BusinessException;
|
|
|
|
|
import com.xydl.cac.iec.IecServerService;
|
|
|
|
|
import com.xydl.cac.iec.RealTimeDataService;
|
|
|
|
|
import com.xydl.cac.model.Response;
|
|
|
|
|
import com.xydl.cac.service.IcdFileConfigService;
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.commons.io.IOUtils;
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import javax.validation.constraints.NotNull;
|
|
|
|
|
import java.nio.charset.Charset;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
|
@Api(tags = {"Iec服务端接口"})
|
|
|
|
@ -23,11 +26,36 @@ import java.util.HashMap;
|
|
|
|
|
@Slf4j
|
|
|
|
|
public class IecServerController extends BasicController {
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
IcdFileConfigService configService;
|
|
|
|
|
@Resource
|
|
|
|
|
IecServerService iecServerService;
|
|
|
|
|
@Resource
|
|
|
|
|
RealTimeDataService realTimeDataService;
|
|
|
|
|
|
|
|
|
|
@PostMapping("upload")
|
|
|
|
|
@ApiOperation("上传服务端icd文件")
|
|
|
|
|
public Response<String> upload(@RequestParam("file") MultipartFile file) throws Exception {
|
|
|
|
|
if (file != null && file.getInputStream() != null) {
|
|
|
|
|
String filename = file.getOriginalFilename();
|
|
|
|
|
String content = IOUtils.toString(file.getInputStream(), Charset.forName("UTF-8"));
|
|
|
|
|
configService.upload(content, filename, 1);
|
|
|
|
|
return Response.success("OK");
|
|
|
|
|
} else {
|
|
|
|
|
return Response.fail("缺少上传文件");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("listFile")
|
|
|
|
|
@ApiOperation("查询服务端icd文件列表")
|
|
|
|
|
public Response<List<IcdFile>> listFile() throws Exception {
|
|
|
|
|
List<IcdFile> result = configService.listFile(1);
|
|
|
|
|
for (IcdFile file : result) {
|
|
|
|
|
file.setXml(null);
|
|
|
|
|
}
|
|
|
|
|
return Response.success(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PostMapping("start")
|
|
|
|
|
@ApiOperation("启动IEC服务端")
|
|
|
|
|
public Response<String> start(@Validated @NotNull(message = "fileId不能为空!") Integer fileId) throws Exception {
|
|
|
|
|