diff --git a/wms_pro/hd/nladmin-system/src/main/java/org/nl/wms/pda_manage/common/PdaCommonController.java b/wms_pro/hd/nladmin-system/src/main/java/org/nl/wms/pda_manage/common/PdaCommonController.java index e41002fe..cb6590c8 100644 --- a/wms_pro/hd/nladmin-system/src/main/java/org/nl/wms/pda_manage/common/PdaCommonController.java +++ b/wms_pro/hd/nladmin-system/src/main/java/org/nl/wms/pda_manage/common/PdaCommonController.java @@ -12,17 +12,19 @@ import org.nl.wms.dispatch_manage.point.service.ISchBasePointService; import org.nl.wms.dispatch_manage.point.service.dao.SchBasePoint; import org.nl.wms.external_system.acs.service.WmsToAcsService; import org.nl.wms.pda_manage.devicemanage.dto.ComTp; +import org.nl.wms.system_manage.service.param.ISysParamService; +import org.nl.wms.system_manage.service.param.dao.Param; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; +import javax.servlet.http.HttpServletResponse; +import java.io.*; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Map; /** *公共接口 @@ -30,19 +32,18 @@ import java.util.List; * @since 2024-03-28 */ @RestController -@RequestMapping("api/pda/common") +@RequestMapping("api/pda") public class PdaCommonController { + @Autowired - private WmsToAcsService wmsToAcsService; - @Autowired - private ISchBasePointService iSchBasePointService; + private ISysParamService iSysParamService; /** * 仓库编码 * @return */ - @PostMapping("/storList") + @PostMapping("common/storList") @SaIgnore @Log("仓库编码") public ResponseEntity> storList() { @@ -53,6 +54,76 @@ public class PdaCommonController { return new ResponseEntity<>(TableDataInfo.build(list),HttpStatus.OK); } + @PostMapping("/update") + @Log("获取升级地址") + @SaIgnore + public ResponseEntity apkUrl() { + Map of = MapOf.of("versionName", "1.0.1", "url", "http://192.168.10.54:8012/api/pda/download/app-release"); + return new ResponseEntity<>(of,HttpStatus.OK); + } + @RequestMapping("/download/app-release") + @SaIgnore + public void setPrint(HttpServletResponse response) throws Exception { + Param byCode = iSysParamService.findByCode("apkurl"); + if (byCode==null){ + throw new BadRequestException("更新失败:为配置apk下载地址"); + } + downloadFile(response,byCode.getValue(),"release"); + } + + /** + * 附件下载 + * @param response + * @param fileName + * @param path + * @return + * @throws Exception + */ + public void downloadFile(HttpServletResponse response, String path, String fileName) throws Exception { + if (fileName != null) { + //设置文件路径 + File file = new File(path); + if (file.exists()) { + response.setHeader("content-type", "application/octet-stream"); + response.setContentType("application/octet-stream"); + try { + response.setHeader("Content-Disposition", "attachment;filename="+new String(fileName.getBytes("utf-8"),"ISO-8859-1")+".apk"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + byte[] buffer = new byte[1024]; + FileInputStream fis = null; + BufferedInputStream bis = null; + try { + fis = new FileInputStream(file); + bis = new BufferedInputStream(fis); + OutputStream os = response.getOutputStream(); + int i = bis.read(buffer); + while (i != -1) { + os.write(buffer, 0, i); + i = bis.read(buffer); + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (bis != null) { + try { + bis.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + if (fis != null) { + try { + fis.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + } + } } diff --git a/wms_pro/hd/nladmin-system/src/main/resources/config/application.yml b/wms_pro/hd/nladmin-system/src/main/resources/config/application.yml index 6045af20..84f22f1a 100644 --- a/wms_pro/hd/nladmin-system/src/main/resources/config/application.yml +++ b/wms_pro/hd/nladmin-system/src/main/resources/config/application.yml @@ -90,6 +90,7 @@ security: - /api/param/getValueByCode - /plumelog/** - /api/esLog/** + - /api/pda/download/app-release - /api/bigScreenScreen/** - /api/users mybatis-plus: