| | |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.pojo.FGCDFileDownload; |
| | | import com.whyc.service.FGCDFileDownloadService; |
| | | import com.whyc.util.ActionUtil; |
| | | 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; |
| | |
| | | @RestController |
| | | @RequestMapping("FGCDFileDownload") |
| | | @Api(tags = "在线监测-一体机导入记录") |
| | | public class FGCDFileDownloadController { |
| | | public class FGCDFileDownloadController extends BaseController{ |
| | | |
| | | @Autowired |
| | | private FGCDFileDownloadService service; |
| | | @Autowired |
| | | private Environment environment; |
| | | |
| | | @GetMapping("listByDeviceId") |
| | | @ApiOperation(value = "数据导入") |
| | |
| | | return new Response().setII(1, false,null,"读取文件失败"); |
| | | } |
| | | |
| | | @PutMapping("sendCmdToA059_readFile") |
| | | @PostMapping("sendCmdToA059_readFile") |
| | | @ApiOperation(value = "读取设备文件的cmd和ack校验 file_index页码数") |
| | | public Response sendCmdToA059ReadFile(@RequestParam Integer deviceId,@RequestParam Integer fileIndex){ |
| | | List cmdCheck = service.sendCmdToA059ReadFile(deviceId, fileIndex); |
| | |
| | | return new Response().setII(1, false,null,"读取文件超时"); |
| | | } |
| | | |
| | | @PutMapping("sendCmdToA059_downloadFile") |
| | | @PostMapping("sendCmdToA059_downloadFile") |
| | | @ApiOperation(value = "导入设备文件的cmd和ack校验 BattGroupId 电池组id,file_index文件对应的索引号") |
| | | public Response sendCmdToA059DownloadFile(@RequestBody FGCDFileDownload download){ |
| | | boolean cmdCheck = service.sendCmdToA059DownloadFile(download); |
| | |
| | | @GetMapping("readA059Pictrue") |
| | | @ApiOperation(tags = "在线监测-实时监控",value = "读取A059内窥镜图片") |
| | | public Response readA059Pictrue(HttpServletRequest request,@RequestParam String devId){ |
| | | //过滤特殊字符,避免路径遍历攻击 |
| | | devId = ActionUtil.filterFileName(devId); |
| | | /*=========图片保存===========*/ |
| | | ApplicationHome applicationHome = new ApplicationHome(getClass()); |
| | | File jarFile = applicationHome.getDir(); |
| | | //存储A059图片的文件夹 |
| | | //调试版 |
| | | //D:\GitWorkSpace\fg_v2.0\target\classes |
| | | String fileDirName = jarFile.getParentFile().toString()+File.separator+"A059"+File.separator+"images"+File.separator+devId; |
| | | //打包版 |
| | | //String fileDirName = jarFile.toString()+File.separator+"A059"+File.separator+"images"+File.separator+devId; |
| | | 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); |