diff --git a/src/main/java/com/xkrs/microservice/controller/DataFileController.java b/src/main/java/com/xkrs/microservice/controller/DataFileController.java index cad89bb..ace6d81 100644 --- a/src/main/java/com/xkrs/microservice/controller/DataFileController.java +++ b/src/main/java/com/xkrs/microservice/controller/DataFileController.java @@ -68,16 +68,14 @@ public class DataFileController { * @param dataFileQo 数据文件实体 * @param leftFile 左影像文件 * @param rightFile 右影像文件 - * @param token * @return */ @RequestMapping(value="/add",method = RequestMethod.POST) public String uploadDataFile(DataFileQo dataFileQo, @RequestPart("leftFile") MultipartFile leftFile, - @RequestPart("rightFile") MultipartFile rightFile, - @RequestHeader(value="Authorization") String token) { + @RequestPart("rightFile") MultipartFile rightFile) { if(dataFileQo.getFileName() == null){ - return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"文件参数不能为空!",locale); + return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"文件名称不能为空!",locale); } if(leftFile.isEmpty()){ return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"左影像文件为空!",locale); @@ -86,8 +84,8 @@ public class DataFileController { return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"右影像文件为空!",locale); } // 获取当前用户名 - String userName = getTokenUserName(token); - ResultVo resVo = dataFileService.uploadDataFile(dataFileQo,leftFile,rightFile,userName); + //String userName = getTokenUserName(token); + ResultVo resVo = dataFileService.uploadDataFile(dataFileQo,leftFile,rightFile,"userName"); if(resVo.getResultCode()!=0){ return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,resVo.getResultMessage(),locale); } diff --git a/src/main/java/com/xkrs/microservice/service/impl/AsyncServiceImpl.java b/src/main/java/com/xkrs/microservice/service/impl/AsyncServiceImpl.java index 166d3a4..a8d81ac 100644 --- a/src/main/java/com/xkrs/microservice/service/impl/AsyncServiceImpl.java +++ b/src/main/java/com/xkrs/microservice/service/impl/AsyncServiceImpl.java @@ -9,11 +9,8 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; -import javax.annotation.RegEx; import javax.annotation.Resource; -import java.io.BufferedReader; import java.io.IOException; -import java.io.InputStreamReader; /** * 线程池执行 @@ -54,19 +51,14 @@ public class AsyncServiceImpl implements AsyncService { public void executeRunData(Integer id,String dataFileCode,String leftFilePath,String rightFilePath,String maxX,String maxY,String minX,String minY){ String[] params = {gsmExePath,"-l",leftFilePath,"-r",rightFilePath,"-o",gsmOutPath + dataFileCode, "--maxx",maxX,"--maxy",maxY,"--minx",minX,"--miny",minY}; + ProcessBuilder processBuilder = new ProcessBuilder(params); + processBuilder.redirectErrorStream(true); + processBuilder.inheritIO(); try { // 执行命令 - Process process = Runtime.getRuntime().exec(params); - - // 读取执行结果 - BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); - String line; - while ((line = reader.readLine()) != null) { - System.out.println(line); - } - + Process process = processBuilder.start(); // 等待执行结束 - int exitCode = process.waitFor(); + process.waitFor(); DataFileEntity dataFileEntity = dataFileDao.findById(id).get(); dataFileEntity.setRunFlag(2); dataFileDao.save(dataFileEntity); @@ -74,7 +66,7 @@ public class AsyncServiceImpl implements AsyncService { e.printStackTrace(); // 如果出现异常将文件的运行状态改为未运行 DataFileEntity dataFileEntity = dataFileDao.findById(id).get(); - dataFileEntity.setRunFlag(0); + dataFileEntity.setRunFlag(3); dataFileDao.save(dataFileEntity); } //不管运行结果怎么样都把文件锁去掉 diff --git a/src/main/java/com/xkrs/microservice/service/impl/DataFileServiceImpl.java b/src/main/java/com/xkrs/microservice/service/impl/DataFileServiceImpl.java index 8510707..46c10bf 100644 --- a/src/main/java/com/xkrs/microservice/service/impl/DataFileServiceImpl.java +++ b/src/main/java/com/xkrs/microservice/service/impl/DataFileServiceImpl.java @@ -38,9 +38,6 @@ import static com.xkrs.microservice.util.ZipUtil.unZip; @CacheConfig(cacheNames = "DataFileServiceCache") public class DataFileServiceImpl implements DataFileService { - @Value("${my.TempFilePath}") - private String tempFilePath; - @Value("${my.FileServerPath}") private String fileServerPath; @@ -62,7 +59,6 @@ public class DataFileServiceImpl implements DataFileService { * 获取所有数据文件 * @return */ - @Cacheable(keyGenerator = "keyGenerator",unless="#result == null") @Override public Iterable getAllDataFile(){ return dataFileDao.findAll(); @@ -215,7 +211,6 @@ public class DataFileServiceImpl implements DataFileService { mapServiceDao.save(mapServiceEntityOne); } } - return 0; } return 1; diff --git a/src/main/resources/application-dev.properties b/src/main/resources/application-dev.properties index 97ce710..9797b19 100644 --- a/src/main/resources/application-dev.properties +++ b/src/main/resources/application-dev.properties @@ -32,7 +32,7 @@ spring.redis.lettuce.pool.min-idle = 1 spring.redis.lettuce.shutdown-timeout = 0 # 自定义Geoserver服务器地址 -my.GeoserverAddress = http://localhost:9080/geoserver +my.GeoserverAddress = http://172.16.40.31:9080/geoserver my.GeoUsername = admin my.GeoPassword = geoserver my.GeoWorkSpace = gsm_gui