Merge remote-tracking branch 'origin/master'

version1
admin 2 years ago
commit 2b3ec8bc05

@ -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<String> httpEntity = uriUtils.buildHeader(request);
String taskId = request.getHeader("taskId");
ResponseEntity<JSONObject> 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);

Loading…
Cancel
Save