区分业务单据与扫码单据同步

version1
anthonywj 2 years ago
parent a712980a99
commit 3806b4ccef

@ -63,58 +63,66 @@ public class SyncController {
return ResultVOUtils.success("连接成功"); return ResultVOUtils.success("连接成功");
} }
//单据接口直连 //单据接口直连--扫码单据
@RequestMapping("/orderApi/**") @RequestMapping("/orderApi/**")
public Object orderApi(HttpServletRequest request, HttpServletResponse httpServletResponse) { public Object orderApi(HttpServletRequest request, HttpServletResponse httpServletResponse) {
String uri = uriUtils.parseUri(request.getRequestURL().toString()); String uri = uriUtils.parseUri(request.getRequestURL().toString());
log.info(uri); 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; return jsonObject;
} }
private JSONObject redirect(HttpServletRequest request, String uri) { private JSONObject redirect(HttpServletRequest request, String uri, String idDatas, String type) {
RestTemplate restTemplate = new RestTemplate(); RestTemplate restTemplate = new RestTemplate();
HttpEntity<String> httpEntity = uriUtils.buildHeader(request); HttpEntity<String> httpEntity = uriUtils.buildHeader(request);
String taskId = request.getHeader("taskId"); String taskId = request.getHeader("taskId");
ResponseEntity<JSONObject> responseBody = null; ResponseEntity<JSONObject> responseBody = null;
if (request.getMethod().equals("POST")) { if (request.getMethod().equals("POST")) {
//写入日志 //写入日志
writeUploadLog(taskId, httpEntity.getBody()); writeUploadLog(taskId, httpEntity.getBody(), idDatas, type);
responseBody = restTemplate.postForEntity(uri, httpEntity, JSONObject.class); responseBody = restTemplate.postForEntity(uri, httpEntity, JSONObject.class);
} else if (request.getMethod().equals("GET")) { } 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); responseBody = restTemplate.exchange(uri, HttpMethod.GET, httpEntity, JSONObject.class);
} }
JSONObject result = responseBody.getBody(); JSONObject result = responseBody.getBody();
return result; return result;
} }
@Async @Async
public void writeUploadLog(String taskId, String content) { public void writeUploadLog(String taskId, String content, String idDatas, String type) {
String key = gennerOrderUtils.getOrders(); String key = gennerOrderUtils.getOrders();
BasicUploadStatusEntity basicUploadStatusEntity = new BasicUploadStatusEntity(); BasicUploadStatusEntity basicUploadStatusEntity = new BasicUploadStatusEntity();
basicUploadStatusEntity.setId(key); basicUploadStatusEntity.setId(key);
basicUploadStatusEntity.setTaskId(taskId); basicUploadStatusEntity.setTaskId(taskId);
basicUploadStatusEntity.setStartTime(DateUtil.getDateTime()); basicUploadStatusEntity.setStartTime(DateUtil.getDateTime());
basicUploadStatusEntity.setIdDatas(ConstantStatus.SYNC_SCAN_ORDER); basicUploadStatusEntity.setIdDatas(idDatas);
basicUploadStatusEntity.setType(BasicProcessStatus.NEW_ALL_ORDER); basicUploadStatusEntity.setType(type);
basicUploadStatusEntity.setScheduleType(BasicProcessStatus.SCHEDULE_NORMAL); basicUploadStatusEntity.setScheduleType(BasicProcessStatus.SCHEDULE_NORMAL);
basicUploadService.insertDownloadStatus(basicUploadStatusEntity); basicUploadService.insertDownloadStatus(basicUploadStatusEntity);
FileUtils.makeDirectory(filePath + "upload/"); 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); FileUtils.SaveFileAs(content, fileName);
} }
@Async @Async
public void writeDownloadLog(String taskId, String content) { public void writeDownloadLog(String taskId, String content, String idDatas, String type) {
String key = gennerOrderUtils.getOrders(); String key = gennerOrderUtils.getOrders();
BasicExportStatusEntity myEntity = new BasicExportStatusEntity(); BasicExportStatusEntity myEntity = new BasicExportStatusEntity();
myEntity.setId(key); myEntity.setId(key);
myEntity.setUpdateTime(new Date()); myEntity.setUpdateTime(new Date());
myEntity.setType(BasicProcessStatus.NEW_ALL_DATA); myEntity.setType(type);
myEntity.setIdDatas(ConstantStatus.SYNC_SCAN_ORDER); myEntity.setIdDatas(idDatas);
myEntity.setStartTime(DateUtil.getDateTime()); myEntity.setStartTime(DateUtil.getDateTime());
myEntity.setTaskId(taskId); myEntity.setTaskId(taskId);
myEntity.setStatus(Constant.SYNC_STATUS_WAIT); myEntity.setStatus(Constant.SYNC_STATUS_WAIT);

Loading…
Cancel
Save