From 3806b4ccef9a7c445f6dffd8447ab9cdaf39617f Mon Sep 17 00:00:00 2001 From: anthonywj Date: Sat, 1 Apr 2023 13:23:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8C=BA=E5=88=86=E4=B8=9A=E5=8A=A1=E5=8D=95?= =?UTF-8?q?=E6=8D=AE=E4=B8=8E=E6=89=AB=E7=A0=81=E5=8D=95=E6=8D=AE=E5=90=8C?= =?UTF-8?q?=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controller/sync/SyncController.java | 34 ++++++++++++------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/api-admin/src/main/java/com/glxp/sale/admin/controller/sync/SyncController.java b/api-admin/src/main/java/com/glxp/sale/admin/controller/sync/SyncController.java index 8ae08df..8805ba1 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/controller/sync/SyncController.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/controller/sync/SyncController.java @@ -63,58 +63,66 @@ public class SyncController { return ResultVOUtils.success("连接成功"); } - //单据接口直连 + //单据接口直连--扫码单据 @RequestMapping("/orderApi/**") public Object orderApi(HttpServletRequest request, HttpServletResponse httpServletResponse) { String uri = uriUtils.parseUri(request.getRequestURL().toString()); log.info(uri); - JSONObject jsonObject = redirect(request, uri); + JSONObject jsonObject = redirect(request, uri, ConstantStatus.SYNC_SCAN_ORDER, BasicProcessStatus.NEW_ALL_ORDER); + return jsonObject; + } + + //单据接口直连---业务单据 + @RequestMapping("/busOrderApi/**") + public Object busOrderApi(HttpServletRequest request, HttpServletResponse httpServletResponse) { + String uri = uriUtils.parseUri(request.getRequestURL().toString()); + log.info(uri); + JSONObject jsonObject = redirect(request, uri, ConstantStatus.SYNC_SCAN_ORDER, BasicProcessStatus.NEW_ALL_ORDER); return jsonObject; } - private JSONObject redirect(HttpServletRequest request, String uri) { + private JSONObject redirect(HttpServletRequest request, String uri, String idDatas, String type) { RestTemplate restTemplate = new RestTemplate(); HttpEntity httpEntity = uriUtils.buildHeader(request); String taskId = request.getHeader("taskId"); ResponseEntity responseBody = null; if (request.getMethod().equals("POST")) { //写入日志 - writeUploadLog(taskId, httpEntity.getBody()); + writeUploadLog(taskId, httpEntity.getBody(), idDatas, type); responseBody = restTemplate.postForEntity(uri, httpEntity, JSONObject.class); } else if (request.getMethod().equals("GET")) { - writeDownloadLog(taskId, httpEntity.getBody()); + writeDownloadLog(taskId, httpEntity.getBody(), idDatas, type); responseBody = restTemplate.exchange(uri, HttpMethod.GET, httpEntity, JSONObject.class); - } JSONObject result = responseBody.getBody(); return result; } @Async - public void writeUploadLog(String taskId, String content) { + public void writeUploadLog(String taskId, String content, String idDatas, String type) { String key = gennerOrderUtils.getOrders(); BasicUploadStatusEntity basicUploadStatusEntity = new BasicUploadStatusEntity(); basicUploadStatusEntity.setId(key); basicUploadStatusEntity.setTaskId(taskId); basicUploadStatusEntity.setStartTime(DateUtil.getDateTime()); - basicUploadStatusEntity.setIdDatas(ConstantStatus.SYNC_SCAN_ORDER); - basicUploadStatusEntity.setType(BasicProcessStatus.NEW_ALL_ORDER); + basicUploadStatusEntity.setIdDatas(idDatas); + basicUploadStatusEntity.setType(type); basicUploadStatusEntity.setScheduleType(BasicProcessStatus.SCHEDULE_NORMAL); basicUploadService.insertDownloadStatus(basicUploadStatusEntity); FileUtils.makeDirectory(filePath + "upload/"); - String fileName = filePath + "upload/" + BasicProcessStatus.NEW_ALL_ORDER + "-" + taskId + ".udi"; + String fileName = filePath + "upload/" + type + "-" + taskId + ".udi"; FileUtils.SaveFileAs(content, fileName); } @Async - public void writeDownloadLog(String taskId, String content) { + public void writeDownloadLog(String taskId, String content, String idDatas, String type) { String key = gennerOrderUtils.getOrders(); BasicExportStatusEntity myEntity = new BasicExportStatusEntity(); myEntity.setId(key); myEntity.setUpdateTime(new Date()); - myEntity.setType(BasicProcessStatus.NEW_ALL_DATA); - myEntity.setIdDatas(ConstantStatus.SYNC_SCAN_ORDER); + myEntity.setType(type); + myEntity.setIdDatas(idDatas); myEntity.setStartTime(DateUtil.getDateTime()); myEntity.setTaskId(taskId); myEntity.setStatus(Constant.SYNC_STATUS_WAIT);