| | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.system.ApplicationHome; |
| | | import org.springframework.core.env.Environment; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.io.File; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | @RestController |
| | |
| | | |
| | | @Autowired |
| | | private FGCDFileDownloadService service; |
| | | @Autowired |
| | | private Environment environment; |
| | | |
| | | @GetMapping("listByDeviceId") |
| | | @ApiOperation(value = "数据导入") |
| | |
| | | @PutMapping("sendCmdToA059_readFile") |
| | | @ApiOperation(value = "读取设备文件的cmd和ack校验 file_index页码数") |
| | | public Response sendCmdToA059ReadFile(@RequestParam Integer deviceId,@RequestParam Integer fileIndex){ |
| | | boolean cmdCheck = service.sendCmdToA059ReadFile(deviceId, fileIndex); |
| | | if(cmdCheck){ |
| | | return new Response().setII(1, true,null,"读取文件成功"); |
| | | List cmdCheck = service.sendCmdToA059ReadFile(deviceId, fileIndex); |
| | | if((boolean)cmdCheck.get(0)){ |
| | | return new Response().setII(1, true,cmdCheck.get(1),"读取文件成功"); |
| | | } |
| | | return new Response().setII(1, false,null,"读取文件失败"); |
| | | return new Response().setII(1, false,null,"读取文件超时"); |
| | | } |
| | | |
| | | @PutMapping("sendCmdToA059_downloadFile") |
| | |
| | | return new Response().setII(1, false,null,"文件开始下载失败"); |
| | | } |
| | | |
| | | @GetMapping("readA059Pictrue") |
| | | @ApiOperation(tags = "在线监测-实时监控",value = "读取A059内窥镜图片") |
| | | public Response readA059Pictrue(HttpServletRequest request,@RequestParam String devId){ |
| | | /*=========图片保存===========*/ |
| | | ApplicationHome applicationHome = new ApplicationHome(getClass()); |
| | | File jarFile = applicationHome.getDir(); |
| | | //存储A059图片的文件夹 |
| | | //调试版 |
| | | //D:\GitWorkSpace\fg_v2.0\target\classes |
| | | int configType = Integer.parseInt(environment.getProperty("configFile.type")); |
| | | String fileDirName = ""; |
| | | //测试版 |
| | | if(configType==1){ |
| | | fileDirName = jarFile.getParentFile().toString()+File.separator+"A059"+File.separator+"images"+File.separator+devId; |
| | | }else{ |
| | | //打包版 |
| | | fileDirName = jarFile.toString()+File.separator+"A059"+File.separator+"images"+File.separator+devId; |
| | | } |
| | | |
| | | //图片的Url |
| | | File file = new File(fileDirName); |
| | | if(file.exists()){ |
| | | File[] files = file.listFiles(); |
| | | return new Response().set(1,files); |
| | | }else{ |
| | | return new Response().set(1,new ArrayList<>()); |
| | | } |
| | | } |
| | | |
| | | } |