From bcf39456432cb66a38e217d9363232a1180c71e4 Mon Sep 17 00:00:00 2001
From: anthonyywj2 <353682448@qq.com>
Date: Sun, 19 Jun 2022 16:03:17 +0800
Subject: [PATCH] =?UTF-8?q?bug=E4=BF=AE=E5=A4=8D=EF=BC=8C=E7=BD=91?=
=?UTF-8?q?=E7=BB=9C=E6=96=AD=E5=BC=80=E6=83=85=E5=86=B5=E4=B8=8B=E4=BF=AE?=
=?UTF-8?q?=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
api-admin/pom.xml | 8 +
.../sync/BasicDownloadController.java | 4 +-
.../sync/SpsSyncDataController.java | 54 +++--
.../entity/sync/BasicExportStatusEntity.java | 1 +
.../entity/sync/BasicUploadStatusEntity.java | 2 +
.../admin/handler/GlobalExceptionHandler.java | 2 +-
.../admin/res/sync/SpSyncUdiResponse.java | 14 ++
.../admin/res/sync/SpsSyncOrderResponse.java | 2 +-
.../sync/impl/BasicExportServiceImpl.java | 2 +-
.../sale/admin/thread/DlAllDataService.java | 208 ++++++++++-------
.../admin/thread/ScanDownloadService.java | 74 +++---
.../sale/admin/thread/ScanUploadService.java | 107 +++++++--
.../com/glxp/sale/admin/util/Constant.java | 8 +
.../com/glxp/sale/admin/util/FileUtils.java | 6 +-
.../sale/admin/util/GennerOrderUtils.java | 220 ++++++++++++++++++
.../glxp/sale/admin/util/OrderNoTypeBean.java | 45 ++++
.../mybatis/mapper/sync/BasicExportDao.xml | 6 +-
.../mybatis/mapper/sync/BasicUploadDao.xml | 7 +-
18 files changed, 589 insertions(+), 181 deletions(-)
create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/util/GennerOrderUtils.java
create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/util/OrderNoTypeBean.java
diff --git a/api-admin/pom.xml b/api-admin/pom.xml
index ecc4d68..29d5968 100644
--- a/api-admin/pom.xml
+++ b/api-admin/pom.xml
@@ -352,6 +352,14 @@
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+ 11
+ 11
+
+
diff --git a/api-admin/src/main/java/com/glxp/sale/admin/controller/sync/BasicDownloadController.java b/api-admin/src/main/java/com/glxp/sale/admin/controller/sync/BasicDownloadController.java
index 6f0f077..2df858d 100644
--- a/api-admin/src/main/java/com/glxp/sale/admin/controller/sync/BasicDownloadController.java
+++ b/api-admin/src/main/java/com/glxp/sale/admin/controller/sync/BasicDownloadController.java
@@ -84,10 +84,8 @@ public class BasicDownloadController {
SpsSyncOrderResponse spsSyncDataResponse = (SpsSyncOrderResponse) redisUtil.get(basicExportStatusRequest.getId() + "");
basicExportService.finished(basicExportStatusRequest.getId());
return ResultVOUtils.success(spsSyncDataResponse);
- } else if (basicExportStatusRequest.getType() == BasicProcessStatus.NEW_ALL_UDIS) {//单据
-
+ } else if (basicExportStatusRequest.getType() == BasicProcessStatus.NEW_ALL_UDIS) {//国家库信息
BasicExportStatusEntity basicExportStatusEntity = basicExportService.findById(basicExportStatusRequest.getId());
-
String data = (String) redisUtil.get(basicExportStatusRequest.getId() + "");
SpSyncUdiResponse spSyncUdiResponse = JSONObject.parseObject(data, new TypeReference() {
});
diff --git a/api-admin/src/main/java/com/glxp/sale/admin/controller/sync/SpsSyncDataController.java b/api-admin/src/main/java/com/glxp/sale/admin/controller/sync/SpsSyncDataController.java
index feba471..88daf73 100644
--- a/api-admin/src/main/java/com/glxp/sale/admin/controller/sync/SpsSyncDataController.java
+++ b/api-admin/src/main/java/com/glxp/sale/admin/controller/sync/SpsSyncDataController.java
@@ -11,10 +11,7 @@ import com.glxp.sale.admin.req.sync.SpsSyncDataRequest;
import com.glxp.sale.admin.res.sync.*;
import com.glxp.sale.admin.service.param.SystemParamConfigService;
import com.glxp.sale.admin.service.sync.BasicUploadService;
-import com.glxp.sale.admin.util.CustomUtil;
-import com.glxp.sale.admin.util.DateUtil;
-import com.glxp.sale.admin.util.FileUtils;
-import com.glxp.sale.admin.util.RedisUtil;
+import com.glxp.sale.admin.util.*;
import com.glxp.sale.common.enums.ResultEnum;
import com.glxp.sale.common.res.BaseResponse;
import com.glxp.sale.common.util.ResultVOUtils;
@@ -39,6 +36,8 @@ public class SpsSyncDataController {
SpPostHttp spPostHttp;
@Resource
private BasicUploadService basicUploadService;
+ @Resource
+ private GennerOrderUtils gennerOrderUtils;
private static final Logger logger = LoggerFactory.getLogger(SpsSyncDataController.class);
@@ -91,9 +90,9 @@ public class SpsSyncDataController {
}
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("sync_upstream_enable");
-
+ String key = gennerOrderUtils.getAllProducts();
BasicUploadStatusEntity basicUploadStatusEntity = new BasicUploadStatusEntity();
- basicUploadStatusEntity.setId(CustomUtil.getId());
+ basicUploadStatusEntity.setId(key);
basicUploadStatusEntity.setTaskId(syncDataResponse.getTaskId());
basicUploadStatusEntity.setStartTime(DateUtil.getDateTime());
basicUploadStatusEntity.setIdDatas(ConstantStatus.SYNC_BASIC_DATA);
@@ -102,13 +101,15 @@ public class SpsSyncDataController {
if (systemParamConfigEntity.getParamValue().equals("0")) {//上游不通
String path = getPath();
- String fileName = path + FileConstant.lowerWaitCopy_products + "BaseData_" + DateUtil.formatDate(new Date(), "yyyyMMddHHmmss") + ".UpperIn";
+ String fileName = path + FileConstant.lowerWaitCopy_products + key + ".UpperIn";
String datas = JSON.toJSONString(syncDataResponse);
FileUtils.SaveFileAs(datas, fileName);
+
+ basicUploadStatusEntity.setCacheFilePath(fileName);
basicUploadStatusEntity.setTransportType(BasicProcessStatus.FILE_TYPE);
basicUploadStatusEntity.setUpdateTime(new Date());
basicUploadStatusEntity.setEndTime(DateUtil.getDateTime());
- basicUploadStatusEntity.setStatus(1);
+ basicUploadStatusEntity.setStatus(Constant.SYNC_STATUS_SUCCESS);
basicUploadService.insertDownloadStatus(basicUploadStatusEntity);
return ResultVOUtils.success("文件上传成功,已保存,等待拷贝!");
} else {
@@ -118,9 +119,9 @@ public class SpsSyncDataController {
basicUploadStatusEntity.setEndTime(DateUtil.getDateTime());
basicUploadStatusEntity.setUpdateTime(new Date());
if (response.getCode() == 20000) {
- basicUploadStatusEntity.setStatus(1);
+ basicUploadStatusEntity.setStatus(Constant.SYNC_STATUS_SUCCESS);
} else {
- basicUploadStatusEntity.setStatus(0);
+ basicUploadStatusEntity.setStatus(Constant.SYNC_STATUS_FAIL);
}
basicUploadService.insertDownloadStatus(basicUploadStatusEntity);
return response;
@@ -135,9 +136,9 @@ public class SpsSyncDataController {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("sync_upstream_enable");
-
+ String key = gennerOrderUtils.getOrders();
BasicUploadStatusEntity basicUploadStatusEntity = new BasicUploadStatusEntity();
- basicUploadStatusEntity.setId(CustomUtil.getId());
+ basicUploadStatusEntity.setId(key);
basicUploadStatusEntity.setTaskId(spsSyncOrderResponse.getTaskId());
basicUploadStatusEntity.setStartTime(DateUtil.getDateTime());
basicUploadStatusEntity.setIdDatas(ConstantStatus.SYNC_SCAN_ORDER);
@@ -146,15 +147,15 @@ public class SpsSyncDataController {
if (systemParamConfigEntity.getParamValue().equals("0")) {//上游不通
String path = getPath();
- String fileName = path + FileConstant.lowerWaitCopy_products + "order_" + DateUtil.formatDate(new Date(), "yyyyMMddHHmmss") + ".UpperIn";
+ String fileName = path + FileConstant.lowerWaitCopy_products + key + ".UpperIn";
String datas = JSON.toJSONString(spsSyncOrderResponse);
FileUtils.SaveFileAs(datas, fileName);
-
basicUploadStatusEntity.setUpdateTime(new Date());
basicUploadStatusEntity.setEndTime(DateUtil.getDateTime());
basicUploadStatusEntity.setTransportType(BasicProcessStatus.FILE_TYPE);
- basicUploadStatusEntity.setStatus(1);
-
+ basicUploadStatusEntity.setCacheFilePath(fileName);
+ basicUploadStatusEntity.setStatus(Constant.SYNC_STATUS_SUCCESS);
+ basicUploadService.insertDownloadStatus(basicUploadStatusEntity);
return ResultVOUtils.success("文件上传成功,已保存,等待拷贝!");
} else {
//上游通
@@ -163,9 +164,9 @@ public class SpsSyncDataController {
basicUploadStatusEntity.setEndTime(DateUtil.getDateTime());
basicUploadStatusEntity.setTransportType(BasicProcessStatus.INTERFACE_TYPE);
if (response.getCode() == 20000) {
- basicUploadStatusEntity.setStatus(1);
+ basicUploadStatusEntity.setStatus(Constant.SYNC_STATUS_SUCCESS);
} else {
- basicUploadStatusEntity.setStatus(0);
+ basicUploadStatusEntity.setStatus(Constant.SYNC_STATUS_FAIL);
}
basicUploadService.insertDownloadStatus(basicUploadStatusEntity);
return response;
@@ -181,9 +182,9 @@ public class SpsSyncDataController {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("sync_upstream_enable");
-
+ String key = gennerOrderUtils.getBusType();
BasicUploadStatusEntity basicUploadStatusEntity = new BasicUploadStatusEntity();
- basicUploadStatusEntity.setId(CustomUtil.getId());
+ basicUploadStatusEntity.setId(key);
basicUploadStatusEntity.setTaskId(spsSyncBusResponse.getTaskId());
basicUploadStatusEntity.setStartTime(DateUtil.getDateTime());
basicUploadStatusEntity.setIdDatas(ConstantStatus.SYNC_BUS_TYPE);
@@ -192,14 +193,14 @@ public class SpsSyncDataController {
if (systemParamConfigEntity.getParamValue().equals("0")) {//上游不通
String path = getPath();
- String fileName = path + FileConstant.lowerWaitCopy_products + "BusType_" + DateUtil.formatDate(new Date(), "yyyyMMddHHmmss") + ".UpperIn";
+ String fileName = path + FileConstant.lowerWaitCopy_products + key + ".UpperIn";
String datas = JSON.toJSONString(spsSyncBusResponse);
FileUtils.SaveFileAs(datas, fileName);
-
basicUploadStatusEntity.setUpdateTime(new Date());
basicUploadStatusEntity.setEndTime(DateUtil.getDateTime());
basicUploadStatusEntity.setTransportType(BasicProcessStatus.FILE_TYPE);
- basicUploadStatusEntity.setStatus(1);
+ basicUploadStatusEntity.setCacheFilePath(fileName);
+ basicUploadStatusEntity.setStatus(Constant.SYNC_STATUS_SUCCESS);
basicUploadService.insertDownloadStatus(basicUploadStatusEntity);
return ResultVOUtils.success("文件上传成功,已保存,等待拷贝!");
@@ -210,9 +211,9 @@ public class SpsSyncDataController {
basicUploadStatusEntity.setEndTime(DateUtil.getDateTime());
basicUploadStatusEntity.setTransportType(BasicProcessStatus.INTERFACE_TYPE);
if (response.getCode() == 20000) {
- basicUploadStatusEntity.setStatus(0);
+ basicUploadStatusEntity.setStatus(Constant.SYNC_STATUS_SUCCESS);
} else {
- basicUploadStatusEntity.setStatus(1);
+ basicUploadStatusEntity.setStatus(Constant.SYNC_STATUS_FAIL);
}
basicUploadService.insertDownloadStatus(basicUploadStatusEntity);
return response;
@@ -223,7 +224,6 @@ public class SpsSyncDataController {
@PostMapping("sps/sync/schedule/upload")
public BaseResponse postSchedule(@RequestBody SpsSyncScheduleResponse spsSyncScheduleResponse) {
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("sync_upstream_enable");
-
BasicUploadStatusEntity basicUploadStatusEntity = new BasicUploadStatusEntity();
basicUploadStatusEntity.setId(CustomUtil.getId());
basicUploadStatusEntity.setStartTime(DateUtil.getDateTime());
@@ -234,13 +234,11 @@ public class SpsSyncDataController {
String fileName = path + FileConstant.lowerWaitCopy_products + "ScheduleList_" + DateUtil.formatDate(new Date(), "yyyyMMddHHmmss") + ".UpperIn";
String datas = JSON.toJSONString(spsSyncScheduleResponse);
FileUtils.SaveFileAs(datas, fileName);
-
basicUploadStatusEntity.setUpdateTime(new Date());
basicUploadStatusEntity.setEndTime(DateUtil.getDateTime());
basicUploadStatusEntity.setStatus(1);
basicUploadStatusEntity.setTransportType(BasicProcessStatus.FILE_TYPE);
basicUploadService.insertDownloadStatus(basicUploadStatusEntity);
-
return ResultVOUtils.success("文件上传成功,已保存,等待拷贝!");
} else {
//上游通
diff --git a/api-admin/src/main/java/com/glxp/sale/admin/entity/sync/BasicExportStatusEntity.java b/api-admin/src/main/java/com/glxp/sale/admin/entity/sync/BasicExportStatusEntity.java
index a87f61c..6966db7 100644
--- a/api-admin/src/main/java/com/glxp/sale/admin/entity/sync/BasicExportStatusEntity.java
+++ b/api-admin/src/main/java/com/glxp/sale/admin/entity/sync/BasicExportStatusEntity.java
@@ -23,4 +23,5 @@ public class BasicExportStatusEntity {
private String remark;
private String superiorService; //上游服务
private String subordinateService; //下游服务
+ private String cacheFilePath;
}
diff --git a/api-admin/src/main/java/com/glxp/sale/admin/entity/sync/BasicUploadStatusEntity.java b/api-admin/src/main/java/com/glxp/sale/admin/entity/sync/BasicUploadStatusEntity.java
index e694a03..72bdfda 100644
--- a/api-admin/src/main/java/com/glxp/sale/admin/entity/sync/BasicUploadStatusEntity.java
+++ b/api-admin/src/main/java/com/glxp/sale/admin/entity/sync/BasicUploadStatusEntity.java
@@ -25,4 +25,6 @@ public class BasicUploadStatusEntity {
private String remark;
private String superiorService; //上游服务
private String subordinateService; //下游服务
+
+ private String cacheFilePath;
}
diff --git a/api-admin/src/main/java/com/glxp/sale/admin/handler/GlobalExceptionHandler.java b/api-admin/src/main/java/com/glxp/sale/admin/handler/GlobalExceptionHandler.java
index 509328c..681b61c 100644
--- a/api-admin/src/main/java/com/glxp/sale/admin/handler/GlobalExceptionHandler.java
+++ b/api-admin/src/main/java/com/glxp/sale/admin/handler/GlobalExceptionHandler.java
@@ -25,7 +25,7 @@ public class GlobalExceptionHandler {
// 拦截API异常
@ExceptionHandler(value = RuntimeException.class)
public BaseResponse handlerRuntimeException(RuntimeException e) {
- log.error(e.getMessage());
+ log.error(e.getMessage(),e);
// 返回对应的错误信息
return ResultVOUtils.error(ResultEnum.NOT_NETWORK);
}
diff --git a/api-admin/src/main/java/com/glxp/sale/admin/res/sync/SpSyncUdiResponse.java b/api-admin/src/main/java/com/glxp/sale/admin/res/sync/SpSyncUdiResponse.java
index e2aa941..f767a40 100644
--- a/api-admin/src/main/java/com/glxp/sale/admin/res/sync/SpSyncUdiResponse.java
+++ b/api-admin/src/main/java/com/glxp/sale/admin/res/sync/SpSyncUdiResponse.java
@@ -1,5 +1,6 @@
package com.glxp.sale.admin.res.sync;
+import cn.hutool.core.collection.CollUtil;
import com.glxp.sale.admin.entity.sync.ProductInfoEntity;
import com.glxp.sale.admin.entity.sync.UdiCompanyEntity;
import lombok.Data;
@@ -13,4 +14,17 @@ public class SpSyncUdiResponse {
private String taskId;
List productInfoEntityList;
List udiCompanyEntities;
+
+
+ @Override
+ public String toString() {
+ StringBuffer remark = new StringBuffer();
+ if (CollUtil.isNotEmpty(productInfoEntityList)) {
+ remark.append("DI产品信息:").append(productInfoEntityList.size()).append(" 条\n");
+ }
+ if (CollUtil.isNotEmpty(udiCompanyEntities)) {
+ remark.append("医疗器械注册人信息:").append(udiCompanyEntities.size()).append(" 条\n");
+ }
+ return remark.toString();
+ }
}
diff --git a/api-admin/src/main/java/com/glxp/sale/admin/res/sync/SpsSyncOrderResponse.java b/api-admin/src/main/java/com/glxp/sale/admin/res/sync/SpsSyncOrderResponse.java
index 22c49cc..244a6c2 100644
--- a/api-admin/src/main/java/com/glxp/sale/admin/res/sync/SpsSyncOrderResponse.java
+++ b/api-admin/src/main/java/com/glxp/sale/admin/res/sync/SpsSyncOrderResponse.java
@@ -27,7 +27,7 @@ public class SpsSyncOrderResponse {
remark.append("单据详情:").append(orderDetailEntityList.size()).append(" 条\n");
}
if (CollUtil.isNotEmpty(warehouseEntityList)) {
- remark.append("UDI码信息:").append(warehouseEntityList.size()).append(" 条\n");
+ remark.append("单据条码信息:").append(warehouseEntityList.size()).append(" 条\n");
}
return remark.toString();
}
diff --git a/api-admin/src/main/java/com/glxp/sale/admin/service/sync/impl/BasicExportServiceImpl.java b/api-admin/src/main/java/com/glxp/sale/admin/service/sync/impl/BasicExportServiceImpl.java
index 2416805..6a1fb72 100644
--- a/api-admin/src/main/java/com/glxp/sale/admin/service/sync/impl/BasicExportServiceImpl.java
+++ b/api-admin/src/main/java/com/glxp/sale/admin/service/sync/impl/BasicExportServiceImpl.java
@@ -27,7 +27,7 @@ public class BasicExportServiceImpl implements BasicExportService {
basicExportStatusRequest.setId(id);
List basicExportStatusEntities = basicExportDao.filterExportStatus(basicExportStatusRequest);
if (CollUtil.isNotEmpty(basicExportStatusEntities)) {
- basicExportStatusEntities.get(0);
+ return basicExportStatusEntities.get(0);
}
return null;
}
diff --git a/api-admin/src/main/java/com/glxp/sale/admin/thread/DlAllDataService.java b/api-admin/src/main/java/com/glxp/sale/admin/thread/DlAllDataService.java
index 5023390..a1768af 100644
--- a/api-admin/src/main/java/com/glxp/sale/admin/thread/DlAllDataService.java
+++ b/api-admin/src/main/java/com/glxp/sale/admin/thread/DlAllDataService.java
@@ -16,9 +16,7 @@ import com.glxp.sale.admin.res.sync.*;
import com.glxp.sale.admin.service.param.SystemParamConfigService;
import com.glxp.sale.admin.service.sync.BasicExportService;
import com.glxp.sale.admin.thread.didl.AsyncDiDlHelper;
-import com.glxp.sale.admin.util.DateUtil;
-import com.glxp.sale.admin.util.FileUtils;
-import com.glxp.sale.admin.util.RedisUtil;
+import com.glxp.sale.admin.util.*;
import com.glxp.sale.common.res.BaseResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@@ -41,6 +39,8 @@ public class DlAllDataService {
AsyncDiDlHelper asyncDiDlHelper;
@Resource
RedisUtil redisUtil;
+ @Resource
+ GennerOrderUtils gennerOrderUtils;
public void dllNewAllData() {
log.info("下载所有基础信息---");
@@ -82,25 +82,33 @@ public class DlAllDataService {
|| CollUtil.isNotEmpty(syncOrderResponse.getUdiRelevanceEntities())
|| CollUtil.isNotEmpty(syncOrderResponse.getAuthAdminList()))
) {
+
+ String key = gennerOrderUtils.getAllProducts();
+ BasicExportStatusEntity myEntity = new BasicExportStatusEntity();
+ myEntity.setId(key);
+ myEntity.setUpdateTime(new Date());
+ myEntity.setType(BasicProcessStatus.NEW_ALL_DATA);
+ myEntity.setIdDatas(basicExportStatusRequest.getIdDatas());
+ myEntity.setStartTime(DateUtil.getDateTime());
+ myEntity.setTaskId(syncOrderResponse.getTaskId());
+ myEntity.setRemark(syncOrderResponse.toString());
+ myEntity.setStatus(Constant.SYNC_STATUS_WAIT);
+ basicExportService.insertExportStatus(myEntity);
if (downstream.getParamValue().equals("1")) {
- String key = "BaseAllData" + System.currentTimeMillis();
redisUtil.set(key, baseResponse.getData());
- BasicExportStatusEntity myEntity = new BasicExportStatusEntity();
- myEntity.setId(key);
- myEntity.setStatus(0);
- myEntity.setUpdateTime(new Date());
- myEntity.setType(BasicProcessStatus.NEW_ALL_DATA);
+ myEntity.setStatus(Constant.SYNC_STATUS_WAIT_DL);
myEntity.setTransportType(BasicProcessStatus.INTERFACE_TYPE);
- myEntity.setIdDatas(basicExportStatusRequest.getIdDatas());
- myEntity.setStartTime(DateUtil.getDateTime());
- myEntity.setTaskId(syncOrderResponse.getTaskId());
- myEntity.setRemark(syncOrderResponse.toString());
- basicExportService.insertExportStatus(myEntity);
+ basicExportService.updateExportStatus(myEntity);
} else {
String path = getPath();
- String fileName = path + FileConstant.upWaitCopy_products + "BaseData_" + DateUtil.formatDate(new Date(), "yyyyMMddHHmmss") + ".LowerIn";
+ String fileName = path + FileConstant.upWaitCopy_products + key + ".LowerIn";
String datas = JSON.toJSONString(baseResponse.getData());
FileUtils.SaveFileAs(datas, fileName);
+ myEntity.setStatus(Constant.SYNC_STATUS_SUCCESS);
+ myEntity.setEndTime(DateUtil.getDateTime());
+ myEntity.setTransportType(BasicProcessStatus.FILE_TYPE);
+ myEntity.setCacheFilePath(fileName);
+ basicExportService.updateExportStatus(myEntity);
}
}
@@ -156,26 +164,33 @@ public class DlAllDataService {
|| CollUtil.isNotEmpty(syncOrderResponse.getOrderDetailEntityList())
|| CollUtil.isNotEmpty(syncOrderResponse.getWarehouseEntityList()))
) {
+ String key = gennerOrderUtils.getOrders();
+ BasicExportStatusEntity myEntity = new BasicExportStatusEntity();
+ myEntity.setId(key);
+ myEntity.setTaskId(syncOrderResponse.getTaskId());
+ myEntity.setStatus(0);
+ myEntity.setUpdateTime(new Date());
+ myEntity.setStartTime(DateUtil.getDateTime());
+ myEntity.setIdDatas(ConstantStatus.SYNC_SCAN_ORDER);
+ myEntity.setType(BasicProcessStatus.NEW_ALL_ORDER);
+ myEntity.setRemark(syncOrderResponse.toString());
+ basicExportService.insertExportStatus(myEntity);
+ myEntity.setStatus(Constant.SYNC_STATUS_WAIT);
if (downstream.getParamValue().equals("1")) {
- String key = "BaseAllOrder" + System.currentTimeMillis();
redisUtil.set(key, baseResponse.getData());
- BasicExportStatusEntity myEntity = new BasicExportStatusEntity();
- myEntity.setId(key);
- myEntity.setTaskId(syncOrderResponse.getTaskId());
- myEntity.setStatus(0);
- myEntity.setUpdateTime(new Date());
- basicExportStatusEntity.setTransportType(BasicProcessStatus.INTERFACE_TYPE);
- myEntity.setStartTime(DateUtil.getDateTime());
- myEntity.setIdDatas(ConstantStatus.SYNC_SCAN_ORDER);
- myEntity.setType(BasicProcessStatus.NEW_ALL_ORDER);
- myEntity.setRemark(syncOrderResponse.toString());
- basicExportService.insertExportStatus(myEntity);
+ myEntity.setTransportType(BasicProcessStatus.INTERFACE_TYPE);
+ myEntity.setStatus(Constant.SYNC_STATUS_WAIT_DL);
+ basicExportService.updateExportStatus(myEntity);
} else {
String path = getPath();
- String fileName = path + FileConstant.upWaitCopy_products + "order_" + DateUtil.formatDate(new Date(), "yyyyMMddHHmmss") + ".LowerIn";
+ String fileName = path + FileConstant.upWaitCopy_products + key + ".LowerIn";
String datas = JSON.toJSONString(baseResponse.getData());
FileUtils.SaveFileAs(datas, fileName);
-
+ myEntity.setStatus(Constant.SYNC_STATUS_SUCCESS);
+ myEntity.setEndTime(DateUtil.getDateTime());
+ myEntity.setTransportType(BasicProcessStatus.FILE_TYPE);
+ myEntity.setCacheFilePath(fileName);
+ basicExportService.updateExportStatus(myEntity);
}
}
}
@@ -229,25 +244,33 @@ public class DlAllDataService {
|| CollUtil.isNotEmpty(syncOrderResponse.getBussinessOriginTypeEntities())
|| CollUtil.isNotEmpty(syncOrderResponse.getBussinessLocalTypeEntities()))
) {
+ String key = gennerOrderUtils.getBusType();
+ BasicExportStatusEntity myEntity = new BasicExportStatusEntity();
+ myEntity.setId(key);
+ myEntity.setTaskId(syncOrderResponse.getTaskId());
+ myEntity.setStatus(0);
+ myEntity.setUpdateTime(new Date());
+ myEntity.setStartTime(DateUtil.getDateTime());
+ myEntity.setTransportType(BasicProcessStatus.INTERFACE_TYPE);
+ myEntity.setType(BasicProcessStatus.NEW_ALL_BUS);
+ myEntity.setIdDatas(ConstantStatus.SYNC_BUS_TYPE);
+ myEntity.setRemark(syncOrderResponse.toString());
+ basicExportService.insertExportStatus(myEntity);
if (downstream.getParamValue().equals("1")) {
- String key = "BaseAllBusType" + System.currentTimeMillis();
redisUtil.set(key, baseResponse.getData());
- BasicExportStatusEntity myEntity = new BasicExportStatusEntity();
- myEntity.setId(key);
- myEntity.setTaskId(syncOrderResponse.getTaskId());
- myEntity.setStatus(0);
- myEntity.setUpdateTime(new Date());
- myEntity.setStartTime(DateUtil.getDateTime());
+ myEntity.setStatus(Constant.SYNC_STATUS_WAIT_DL);
myEntity.setTransportType(BasicProcessStatus.INTERFACE_TYPE);
- myEntity.setType(BasicProcessStatus.NEW_ALL_BUS);
- myEntity.setIdDatas(ConstantStatus.SYNC_BUS_TYPE);
- myEntity.setRemark(syncOrderResponse.toString());
- basicExportService.insertExportStatus(myEntity);
+ basicExportService.updateExportStatus(myEntity);
} else {
String path = getPath();
- String fileName = path + FileConstant.upWaitCopy_products + "BusType_" + DateUtil.formatDate(new Date(), "yyyyMMddHHmmss") + ".LowerIn";
+ String fileName = path + FileConstant.upWaitCopy_products + key + ".LowerIn";
String datas = JSON.toJSONString(baseResponse.getData());
FileUtils.SaveFileAs(datas, fileName);
+ myEntity.setStatus(Constant.SYNC_STATUS_SUCCESS);
+ myEntity.setEndTime(DateUtil.getDateTime());
+ myEntity.setTransportType(BasicProcessStatus.FILE_TYPE);
+ myEntity.setCacheFilePath(fileName);
+ basicExportService.updateExportStatus(myEntity);
}
}
@@ -327,28 +350,36 @@ public class DlAllDataService {
if (productInfoEntityList != null && productInfoEntityList.size() > 0) {
SpSyncUdiResponse spSyncUdiResponse = new SpSyncUdiResponse();
spSyncUdiResponse.setProductInfoEntityList(productInfoEntityList);
+ spSyncUdiResponse.setTaskId(basicExportStatusEntity.getId());
if (CollUtil.isNotEmpty(spSyncUdiResponse.getProductInfoEntityList()) || CollUtil.isNotEmpty(spSyncUdiResponse.getUdiCompanyEntities())) {
- String key = "UdiPrdoucts" + System.currentTimeMillis();
+ String key = gennerOrderUtils.getSyncUdi();
+ BasicExportStatusEntity myEntity = new BasicExportStatusEntity();
+ myEntity.setId(key);
+ myEntity.setTaskId(basicExportStatusEntity.getId());
+ myEntity.setStatus(0);
+ myEntity.setIdDatas(ConstantStatus.SYNC_DI_PRODUCTS);
+ myEntity.setUpdateTime(new Date());
+ myEntity.setType(BasicProcessStatus.NEW_ALL_UDIS);
+ myEntity.setStartTime(DateUtil.getDateTime());
+ myEntity.setRemark("国家库DI信息:" + spSyncUdiResponse.getProductInfoEntityList().size() + " 条");
+ basicExportService.insertExportStatus(myEntity);
if (downstream.getParamValue().equals("1")) {
String datas = JSON.toJSON(spSyncUdiResponse).toString();
redisUtil.set(key, datas);
//记录下载日志
- BasicExportStatusEntity myEntity = new BasicExportStatusEntity();
- myEntity.setId(key);
- myEntity.setTaskId(basicExportStatusEntity.getId());
- myEntity.setStatus(0);
- myEntity.setIdDatas(ConstantStatus.SYNC_DI_PRODUCTS);
- myEntity.setUpdateTime(new Date());
- myEntity.setType(BasicProcessStatus.NEW_ALL_UDIS);
+ myEntity.setStatus(Constant.SYNC_STATUS_WAIT_DL);
myEntity.setTransportType(BasicProcessStatus.INTERFACE_TYPE);
- myEntity.setStartTime(DateUtil.getDateTime());
- myEntity.setRemark("国家库DI信息:" + spSyncUdiResponse.getProductInfoEntityList().size() + " 条");
- basicExportService.insertExportStatus(myEntity);
+ basicExportService.updateExportStatus(myEntity);
} else {
String path = getPath();
- String fileName = path + FileConstant.upWaitCopy_products + "UdiPrdoucts_" + key + ".LowerIn";
+ String fileName = path + FileConstant.upWaitCopy_products + key + ".LowerIn";
String datas = JSON.toJSON(spSyncUdiResponse).toString();
FileUtils.SaveFileAs(datas, fileName);
+ myEntity.setStatus(Constant.SYNC_STATUS_SUCCESS);
+ myEntity.setEndTime(DateUtil.getDateTime());
+ myEntity.setTransportType(BasicProcessStatus.FILE_TYPE);
+ myEntity.setCacheFilePath(fileName);
+ basicExportService.updateExportStatus(myEntity);
}
}
@@ -371,32 +402,38 @@ public class DlAllDataService {
SpSyncUdiResponse spSyncUdiResponse = new SpSyncUdiResponse();
spSyncUdiResponse.setUdiCompanyEntities(udiCompanyEntities);
+ spSyncUdiResponse.setTaskId(basicExportStatusEntity.getId());
if (CollUtil.isNotEmpty(spSyncUdiResponse.getUdiCompanyEntities()) || CollUtil.isNotEmpty(spSyncUdiResponse.getUdiCompanyEntities())) {
- String key = "UdiPrdoucts" + System.currentTimeMillis();
+ String key = gennerOrderUtils.getSyncUdi();
+ BasicExportStatusEntity myEntity = new BasicExportStatusEntity();
+ myEntity.setId(key);
+ myEntity.setTaskId(basicExportStatusEntity.getId());
+ myEntity.setStatus(0);
+ myEntity.setUpdateTime(new Date());
+ myEntity.setType(BasicProcessStatus.NEW_ALL_UDIS);
+ myEntity.setStartTime(DateUtil.getDateTime());
+ myEntity.setUpdateTime(new Date());
+ myEntity.setIdDatas(ConstantStatus.SYNC_DI_PRODUCTS);
+ myEntity.setRemark("医疗器械注册人信息:{} " + spSyncUdiResponse.getUdiCompanyEntities().size() + " 条");
+ basicExportService.insertExportStatus(myEntity);
if (downstream.getParamValue().equals("1")) {
String datas = JSON.toJSON(spSyncUdiResponse).toString();
redisUtil.set(key, datas);
- BasicExportStatusEntity myEntity = new BasicExportStatusEntity();
- myEntity.setId(key);
- myEntity.setTaskId(basicExportStatusEntity.getId());
- myEntity.setStatus(0);
- myEntity.setUpdateTime(new Date());
- myEntity.setType(BasicProcessStatus.NEW_ALL_UDIS);
+ myEntity.setStatus(Constant.SYNC_STATUS_WAIT_DL);
myEntity.setTransportType(BasicProcessStatus.INTERFACE_TYPE);
- myEntity.setStartTime(DateUtil.getDateTime());
- myEntity.setUpdateTime(new Date());
- myEntity.setIdDatas(ConstantStatus.SYNC_DI_PRODUCTS);
- myEntity.setRemark("公司信息:{} " + spSyncUdiResponse.getUdiCompanyEntities().size() + " 条");
- basicExportService.insertExportStatus(myEntity);
+ basicExportService.updateExportStatus(myEntity);
} else {
String path = getPath();
- String fileName = path + FileConstant.upWaitCopy_products + "UdiPrdoucts_" + key + ".LowerIn";
+ String fileName = path + FileConstant.upWaitCopy_products + key + ".LowerIn";
String datas = JSON.toJSON(spSyncUdiResponse).toString();
FileUtils.SaveFileAs(datas, fileName);
+ myEntity.setStatus(Constant.SYNC_STATUS_SUCCESS);
+ myEntity.setEndTime(DateUtil.getDateTime());
+ myEntity.setTransportType(BasicProcessStatus.FILE_TYPE);
+ myEntity.setCacheFilePath(fileName);
+ basicExportService.updateExportStatus(myEntity);
}
}
-
-
if (udiCompanyEntities.size() < limit1) {
break;
} else {
@@ -417,28 +454,35 @@ public class DlAllDataService {
SpsSyncDataRequest spsSyncDataRequest = new SpsSyncDataRequest();
spsSyncDataRequest.setId(basicExportStatusEntity.getId());
BaseResponse baseResponse = spGetHttp.getAllDi(spsSyncDataRequest);
-
+ String key = gennerOrderUtils.getSyncUdi();
SpSyncUdiResponse spSyncUdiResponse = baseResponse.getData();
+ BasicExportStatusEntity myEntity = new BasicExportStatusEntity();
+ myEntity.setId(key);
+ myEntity.setTaskId(spSyncUdiResponse.getTaskId());
+ myEntity.setStatus(0);
+ myEntity.setUpdateTime(new Date());
+ myEntity.setStartTime(DateUtil.getDateTime());
+ myEntity.setIdDatas(ConstantStatus.SYNC_DI_PRODUCTS);
+ myEntity.setTransportType(BasicProcessStatus.INTERFACE_TYPE);
+ myEntity.setType(BasicProcessStatus.NEW_ALL_UDIS);
+ myEntity.setRemark("国家库DI信息:" + spSyncUdiResponse.getUdiCompanyEntities().size() + " 条\n"
+ + "医疗器械注册人信息:" + spSyncUdiResponse.getUdiCompanyEntities().size() + "条\n");
+ basicExportService.insertExportStatus(myEntity);
if (downstream.getParamValue().equals("1")) {
- String key = "UdiPrdoucts" + System.currentTimeMillis();
redisUtil.set(key, baseResponse.getData());
- BasicExportStatusEntity myEntity = new BasicExportStatusEntity();
- myEntity.setId(key);
- myEntity.setTaskId(spSyncUdiResponse.getTaskId());
- myEntity.setStatus(0);
- myEntity.setUpdateTime(new Date());
- myEntity.setStartTime(DateUtil.getDateTime());
- myEntity.setIdDatas(ConstantStatus.SYNC_DI_PRODUCTS);
+ myEntity.setStatus(Constant.SYNC_STATUS_WAIT_DL);
myEntity.setTransportType(BasicProcessStatus.INTERFACE_TYPE);
- myEntity.setType(BasicProcessStatus.NEW_ALL_UDIS);
- myEntity.setRemark("国家库DI信息:" + spSyncUdiResponse.getUdiCompanyEntities().size() + " 条\n"
- + "公司信息:" + spSyncUdiResponse.getUdiCompanyEntities().size() + "条\n");
- basicExportService.insertExportStatus(myEntity);
+ basicExportService.updateExportStatus(myEntity);
} else {
String path = getPath();
- String fileName = path + FileConstant.upWaitCopy_products + "UdiPrdoucts_" + DateUtil.formatDate(new Date(), "yyyyMMddHHmmss") + ".LowerIn";
+ String fileName = path + FileConstant.upWaitCopy_products + key + ".LowerIn";
String datas = JSON.toJSONString(baseResponse.getData());
FileUtils.SaveFileAs(datas, fileName);
+ myEntity.setStatus(Constant.SYNC_STATUS_SUCCESS);
+ myEntity.setEndTime(DateUtil.getDateTime());
+ myEntity.setTransportType(BasicProcessStatus.FILE_TYPE);
+ myEntity.setCacheFilePath(fileName);
+ basicExportService.updateExportStatus(myEntity);
}
spGetHttp.postDeleteBasicStatus(basicExportStatusEntity.getId());
diff --git a/api-admin/src/main/java/com/glxp/sale/admin/thread/ScanDownloadService.java b/api-admin/src/main/java/com/glxp/sale/admin/thread/ScanDownloadService.java
index fadb5e3..8ce3189 100644
--- a/api-admin/src/main/java/com/glxp/sale/admin/thread/ScanDownloadService.java
+++ b/api-admin/src/main/java/com/glxp/sale/admin/thread/ScanDownloadService.java
@@ -8,16 +8,10 @@ import com.glxp.sale.admin.constant.ConstantStatus;
import com.glxp.sale.admin.constant.FileConstant;
import com.glxp.sale.admin.entity.param.SystemParamConfigEntity;
import com.glxp.sale.admin.entity.sync.BasicExportStatusEntity;
-import com.glxp.sale.admin.res.sync.SpsSyncBusResponse;
-import com.glxp.sale.admin.res.sync.SpsSyncDataResponse;
-import com.glxp.sale.admin.res.sync.SpsSyncOrderResponse;
-import com.glxp.sale.admin.res.sync.SpsSyncScheduleResponse;
+import com.glxp.sale.admin.res.sync.*;
import com.glxp.sale.admin.service.param.SystemParamConfigService;
import com.glxp.sale.admin.service.sync.BasicExportService;
-import com.glxp.sale.admin.util.DateUtil;
-import com.glxp.sale.admin.util.FileFilterImpl;
-import com.glxp.sale.admin.util.FileUtils;
-import com.glxp.sale.admin.util.RedisUtil;
+import com.glxp.sale.admin.util.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
@@ -55,26 +49,26 @@ public class ScanDownloadService {
if (files != null && files.length > 0) {
for (int i = 0; i < files.length; i++) {
File file = files[i];
- if (file.getName().contains("BaseData") && file.getName().contains("LowerIn")) {
+ if (file.getName().contains("AllProducts") && file.getName().contains("LowerIn")) {
String data = FileUtils.readFileAll(file.getPath());
+ SpsSyncDataResponse baseResponse =
+ JSONObject.parseObject(data, new TypeReference() {
+ });
BasicExportStatusEntity basicExportStatusEntity = new BasicExportStatusEntity();
String fileName = file.getName();
+ redisUtil.set(fileName, baseResponse);
basicExportStatusEntity.setId(fileName);
basicExportStatusEntity.setUpdateTime(new Date());
basicExportStatusEntity.setStartTime(DateUtil.getDateTime());
- basicExportStatusEntity.setStatus(1);
- basicExportStatusEntity.setIdDatas(file.getPath());
+ basicExportStatusEntity.setStatus(Constant.SYNC_STATUS_WAIT_DL);
basicExportStatusEntity.setIdDatas(ConstantStatus.SYNC_BASIC_DATA);
basicExportStatusEntity.setType(BasicProcessStatus.NEW_ALL_DATA);
basicExportStatusEntity.setScheduleType(BasicProcessStatus.SCHEDULE_NORMAL);
basicExportStatusEntity.setTransportType(BasicProcessStatus.FILE_TYPE);
SpsSyncDataResponse spsSyncDataResponse = JSONUtil.toBean(data, SpsSyncDataResponse.class);
+ basicExportStatusEntity.setTaskId(spsSyncDataResponse.getTaskId());
basicExportStatusEntity.setRemark(spsSyncDataResponse.toString());
basicExportService.insertExportStatus(basicExportStatusEntity);
- SpsSyncDataResponse baseResponse =
- JSONObject.parseObject(data, new TypeReference() {
- });
- redisUtil.set(fileName, baseResponse);
try {
FileUtils.CutFile(file.getPath(), getPath() + FileConstant.waitDownload_products_back + file.getName());
} catch (Exception e) {
@@ -95,18 +89,21 @@ public class ScanDownloadService {
String data = FileUtils.readFileAll(file.getPath());
BasicExportStatusEntity basicExportStatusEntity = new BasicExportStatusEntity();
String fileName = file.getName();
+ SpsSyncBusResponse baseResponse =
+ JSONObject.parseObject(data, new TypeReference() {
+ });
+ redisUtil.set(fileName, baseResponse);
basicExportStatusEntity.setId(fileName);
basicExportStatusEntity.setUpdateTime(new Date());
- basicExportStatusEntity.setStatus(1);
- basicExportStatusEntity.setIdDatas(file.getPath());
+ basicExportStatusEntity.setStatus(Constant.SYNC_STATUS_WAIT_DL);
+ basicExportStatusEntity.setIdDatas(ConstantStatus.SYNC_BUS_TYPE);
basicExportStatusEntity.setType(BasicProcessStatus.NEW_ALL_BUS);
+ basicExportStatusEntity.setStartTime(DateUtil.getDateTime());
basicExportStatusEntity.setTransportType(BasicProcessStatus.FILE_TYPE);
basicExportStatusEntity.setScheduleType(BasicProcessStatus.SCHEDULE_NORMAL);
+ basicExportStatusEntity.setTaskId(baseResponse.getTaskId());
+ basicExportStatusEntity.setRemark(baseResponse.toString());
basicExportService.insertExportStatus(basicExportStatusEntity);
- SpsSyncBusResponse baseResponse =
- JSONObject.parseObject(data, new TypeReference() {
- });
- redisUtil.set(fileName, baseResponse);
try {
FileUtils.CutFile(file.getPath(), getPath() + FileConstant.waitDownload_products_back + file.getName());
} catch (Exception e) {
@@ -123,22 +120,26 @@ public class ScanDownloadService {
if (files != null && files.length > 0) {
for (int i = 0; i < files.length; i++) {
File file = files[i];
- if (file.getName().contains("order") && file.getName().contains("LowerIn")) {
+ if (file.getName().contains("Orders") && file.getName().contains("LowerIn")) {
String data = FileUtils.readFileAll(file.getPath());
BasicExportStatusEntity basicExportStatusEntity = new BasicExportStatusEntity();
String fileName = file.getName();
+
+ SpsSyncOrderResponse baseResponse =
+ JSONObject.parseObject(data, new TypeReference() {
+ });
+ redisUtil.set(fileName, baseResponse);
basicExportStatusEntity.setId(fileName);
basicExportStatusEntity.setUpdateTime(new Date());
- basicExportStatusEntity.setStatus(1);
- basicExportStatusEntity.setIdDatas(file.getPath());
+ basicExportStatusEntity.setStatus(Constant.SYNC_STATUS_WAIT_DL);
+ basicExportStatusEntity.setIdDatas(ConstantStatus.SYNC_SCAN_ORDER);
basicExportStatusEntity.setTransportType(BasicProcessStatus.FILE_TYPE);
+ basicExportStatusEntity.setStartTime(DateUtil.getDateTime());
basicExportStatusEntity.setType(BasicProcessStatus.NEW_ALL_ORDER);
basicExportStatusEntity.setScheduleType(BasicProcessStatus.SCHEDULE_NORMAL);
+ basicExportStatusEntity.setTaskId(baseResponse.getTaskId());
+ basicExportStatusEntity.setRemark(baseResponse.toString());
basicExportService.insertExportStatus(basicExportStatusEntity);
- SpsSyncOrderResponse baseResponse =
- JSONObject.parseObject(data, new TypeReference() {
- });
- redisUtil.set(fileName, baseResponse);
try {
FileUtils.CutFile(file.getPath(), getPath() + FileConstant.waitDownload_products_back + file.getName());
} catch (Exception e) {
@@ -161,7 +162,6 @@ public class ScanDownloadService {
SpsSyncScheduleResponse baseResponse =
JSONObject.parseObject(data, new TypeReference() {
});
-
for (BasicExportStatusEntity basicExportStatusEntity : baseResponse.getBasicExportStatusEntities()) {
basicExportService.insertExportStatus(basicExportStatusEntity);
}
@@ -185,17 +185,21 @@ public class ScanDownloadService {
String data = FileUtils.readFileAll(file.getPath());
BasicExportStatusEntity basicExportStatusEntity = new BasicExportStatusEntity();
String fileName = file.getName();
+
+ SpSyncUdiResponse baseResponse =
+ JSONObject.parseObject(data, new TypeReference() {
+ });
+ redisUtil.set(fileName, data);
basicExportStatusEntity.setId(fileName);
basicExportStatusEntity.setUpdateTime(new Date());
- basicExportStatusEntity.setStatus(1);
- basicExportStatusEntity.setIdDatas(file.getPath());
+ basicExportStatusEntity.setStatus(Constant.SYNC_STATUS_WAIT_DL);
+ basicExportStatusEntity.setStartTime(DateUtil.getDateTime());
+ basicExportStatusEntity.setIdDatas(ConstantStatus.SYNC_DI_PRODUCTS);
basicExportStatusEntity.setType(BasicProcessStatus.NEW_ALL_UDIS);
basicExportStatusEntity.setScheduleType(BasicProcessStatus.SCHEDULE_NORMAL);
+ basicExportStatusEntity.setTaskId(baseResponse.getTaskId());
+ basicExportStatusEntity.setRemark(baseResponse.toString());
basicExportService.insertExportStatus(basicExportStatusEntity);
- SpsSyncOrderResponse baseResponse =
- JSONObject.parseObject(data, new TypeReference() {
- });
- redisUtil.set(fileName, baseResponse);
try {
FileUtils.CutFile(file.getPath(), getPath() + FileConstant.waitDownload_products_back + file.getName());
} catch (Exception e) {
diff --git a/api-admin/src/main/java/com/glxp/sale/admin/thread/ScanUploadService.java b/api-admin/src/main/java/com/glxp/sale/admin/thread/ScanUploadService.java
index 2793107..ca707a3 100644
--- a/api-admin/src/main/java/com/glxp/sale/admin/thread/ScanUploadService.java
+++ b/api-admin/src/main/java/com/glxp/sale/admin/thread/ScanUploadService.java
@@ -2,9 +2,11 @@ package com.glxp.sale.admin.thread;
import com.alibaba.fastjson.JSON;
import com.glxp.sale.admin.constant.BasicProcessStatus;
+import com.glxp.sale.admin.constant.ConstantStatus;
import com.glxp.sale.admin.constant.FileConstant;
import com.glxp.sale.admin.entity.param.SystemParamConfigEntity;
import com.glxp.sale.admin.entity.sync.BasicExportStatusEntity;
+import com.glxp.sale.admin.entity.sync.BasicUploadStatusEntity;
import com.glxp.sale.admin.entity.sync.IOOrderStatusEntity;
import com.glxp.sale.admin.http.SpGetHttp;
import com.glxp.sale.admin.http.SpPostHttp;
@@ -13,11 +15,9 @@ import com.glxp.sale.admin.req.sync.PostThrProductsRequest;
import com.glxp.sale.admin.res.sync.*;
import com.glxp.sale.admin.service.param.SystemParamConfigService;
import com.glxp.sale.admin.service.sync.BasicExportService;
+import com.glxp.sale.admin.service.sync.BasicUploadService;
import com.glxp.sale.admin.service.sync.IOOrderStatusService;
-import com.glxp.sale.admin.util.Constant;
-import com.glxp.sale.admin.util.FileFilterImpl;
-import com.glxp.sale.admin.util.FileUtils;
-import com.glxp.sale.admin.util.RedisUtil;
+import com.glxp.sale.admin.util.*;
import com.glxp.sale.common.res.BaseResponse;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
@@ -25,6 +25,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.File;
+import java.net.ConnectException;
import java.util.Date;
/**
@@ -38,7 +39,8 @@ public class ScanUploadService {
SpPostHttp spPostHttp;
@Resource
SystemParamConfigService systemParamConfigService;
-
+ @Resource
+ private BasicUploadService basicUploadService;
public String getPath() {
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("share_folder");
@@ -52,17 +54,35 @@ public class ScanUploadService {
if (files != null && files.length > 0) {
for (int i = 0; i < files.length; i++) {
File file = files[i];
- if (file.getName().contains("BaseData") && file.getName().contains("UpperIn")) {
+ if (file.getName().contains("AllProducts") && file.getName().contains("UpperIn")) {
String data = FileUtils.readFileAll(file.getPath());
SpsSyncDataResponse syncDataResponse = JSON.parseObject(data, SpsSyncDataResponse.class);
- BaseResponse baseResponse = spPostHttp.postAllDatas(syncDataResponse);
- if (baseResponse.getCode() == 20000) {//上传成功
- try {
- FileUtils.CutFile(file.getPath(), getPath() + FileConstant.waitUpload_products_back + file.getName());
- } catch (Exception e) {
- e.printStackTrace();
+ BasicUploadStatusEntity basicUploadStatusEntity = new BasicUploadStatusEntity();
+ basicUploadStatusEntity.setId(file.getName());
+ basicUploadStatusEntity.setTaskId(syncDataResponse.getTaskId());
+ basicUploadStatusEntity.setStartTime(DateUtil.getDateTime());
+ basicUploadStatusEntity.setIdDatas(ConstantStatus.SYNC_BASIC_DATA);
+ basicUploadStatusEntity.setType(BasicProcessStatus.NEW_ALL_DATA);
+ basicUploadStatusEntity.setRemark(syncDataResponse.toString());
+
+ try {
+ BaseResponse baseResponse = spPostHttp.postAllDatas(syncDataResponse);
+ if (baseResponse.getCode() == 20000) {//上传成功
+ basicUploadStatusEntity.setEndTime(DateUtil.getDateTime());
+ basicUploadStatusEntity.setStatus(Constant.SYNC_STATUS_SUCCESS);
+ try {
+ FileUtils.CutFile(file.getPath(), getPath() + FileConstant.waitUpload_products_back + file.getName());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ } else {
+ basicUploadStatusEntity.setStatus(Constant.SYNC_STATUS_FAIL);
}
+ } catch (Exception e) {
+ e.printStackTrace();
+ basicUploadStatusEntity.setStatus(Constant.SYNC_STATUS_FAIL);
}
+ basicUploadService.insertDownloadStatus(basicUploadStatusEntity);
}
}
}
@@ -76,15 +96,34 @@ public class ScanUploadService {
File file = files[i];
if (file.getName().contains("BusType") && file.getName().contains("UpperIn")) {
String data = FileUtils.readFileAll(file.getPath());
+
SpsSyncBusResponse spsSyncBusResponse = JSON.parseObject(data, SpsSyncBusResponse.class);
- BaseResponse baseResponse = spPostHttp.postAllBus(spsSyncBusResponse);
- if (baseResponse.getCode() == 20000) {//上传成功
- try {
- FileUtils.CutFile(file.getPath(), getPath() + FileConstant.waitUpload_products_back + file.getName());
- } catch (Exception e) {
- e.printStackTrace();
+
+ BasicUploadStatusEntity basicUploadStatusEntity = new BasicUploadStatusEntity();
+ basicUploadStatusEntity.setId(file.getName());
+ basicUploadStatusEntity.setTaskId(spsSyncBusResponse.getTaskId());
+ basicUploadStatusEntity.setStartTime(DateUtil.getDateTime());
+ basicUploadStatusEntity.setIdDatas(ConstantStatus.SYNC_BUS_TYPE);
+ basicUploadStatusEntity.setType(BasicProcessStatus.NEW_ALL_DATA);
+ basicUploadStatusEntity.setRemark(spsSyncBusResponse.toString());
+ try {
+ BaseResponse baseResponse = spPostHttp.postAllBus(spsSyncBusResponse);
+ if (baseResponse.getCode() == 20000) {//上传成功
+ basicUploadStatusEntity.setEndTime(DateUtil.getDateTime());
+ basicUploadStatusEntity.setStatus(Constant.SYNC_STATUS_SUCCESS);
+ try {
+ FileUtils.CutFile(file.getPath(), getPath() + FileConstant.waitUpload_products_back + file.getName());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ } else {
+ basicUploadStatusEntity.setStatus(Constant.SYNC_STATUS_FAIL);
}
+ } catch (Exception e) {
+ e.printStackTrace();
+ basicUploadStatusEntity.setStatus(Constant.SYNC_STATUS_FAIL);
}
+ basicUploadService.insertDownloadStatus(basicUploadStatusEntity);
}
}
}
@@ -96,17 +135,35 @@ public class ScanUploadService {
if (files != null && files.length > 0) {
for (int i = 0; i < files.length; i++) {
File file = files[i];
- if (file.getName().contains("order") && file.getName().contains("UpperIn")) {
+ if (file.getName().contains("Orders") && file.getName().contains("UpperIn")) {
String data = FileUtils.readFileAll(file.getPath());
SpsSyncOrderResponse syncOrderResponse = JSON.parseObject(data, SpsSyncOrderResponse.class);
- BaseResponse baseResponse = spPostHttp.postAllOrders(syncOrderResponse);
- if (baseResponse.getCode() == 20000) {//上传成功
- try {
- FileUtils.CutFile(file.getPath(), getPath() + FileConstant.waitUpload_products_back + file.getName());
- } catch (Exception e) {
- e.printStackTrace();
+
+ BasicUploadStatusEntity basicUploadStatusEntity = new BasicUploadStatusEntity();
+ basicUploadStatusEntity.setId(file.getName());
+ basicUploadStatusEntity.setTaskId(syncOrderResponse.getTaskId());
+ basicUploadStatusEntity.setStartTime(DateUtil.getDateTime());
+ basicUploadStatusEntity.setIdDatas(ConstantStatus.SYNC_SCAN_ORDER);
+ basicUploadStatusEntity.setType(BasicProcessStatus.NEW_ALL_DATA);
+ basicUploadStatusEntity.setRemark(syncOrderResponse.toString());
+ try {
+ BaseResponse baseResponse = spPostHttp.postAllOrders(syncOrderResponse);
+ if (baseResponse.getCode() == 20000) {//上传成功
+ basicUploadStatusEntity.setEndTime(DateUtil.getDateTime());
+ basicUploadStatusEntity.setStatus(Constant.SYNC_STATUS_SUCCESS);
+ try {
+ FileUtils.CutFile(file.getPath(), getPath() + FileConstant.waitUpload_products_back + file.getName());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ } else {
+ basicUploadStatusEntity.setStatus(Constant.SYNC_STATUS_FAIL);
}
+ } catch (Exception e) {
+ e.printStackTrace();
+ basicUploadStatusEntity.setStatus(Constant.SYNC_STATUS_FAIL);
}
+ basicUploadService.insertDownloadStatus(basicUploadStatusEntity);
}
}
}
diff --git a/api-admin/src/main/java/com/glxp/sale/admin/util/Constant.java b/api-admin/src/main/java/com/glxp/sale/admin/util/Constant.java
index 11b6f43..ac0c3f1 100644
--- a/api-admin/src/main/java/com/glxp/sale/admin/util/Constant.java
+++ b/api-admin/src/main/java/com/glxp/sale/admin/util/Constant.java
@@ -8,4 +8,12 @@ public class Constant {
public static final String dlThrCorps = "THR_DOWNLOAD_CORPS";
+ public static final String SERIAL_CACHE_PREFIX = "serial_";
+ public static final String SERIAL_CACHE_PREFIX_ST = "serialst_";
+ public static final String SERIAL_CACHE_SYNC_UDI = "syncUdi";
+
+ public static final int SYNC_STATUS_SUCCESS = 1; //处理成功
+ public static final int SYNC_STATUS_FAIL = 2; //处理失败
+ public static final int SYNC_STATUS_WAIT = 0; //等待处理
+ public static final int SYNC_STATUS_WAIT_DL = 3; //等待下游下载
}
diff --git a/api-admin/src/main/java/com/glxp/sale/admin/util/FileUtils.java b/api-admin/src/main/java/com/glxp/sale/admin/util/FileUtils.java
index 89c2cba..ee97318 100644
--- a/api-admin/src/main/java/com/glxp/sale/admin/util/FileUtils.java
+++ b/api-admin/src/main/java/com/glxp/sale/admin/util/FileUtils.java
@@ -1,8 +1,11 @@
package com.glxp.sale.admin.util;
+import cn.hutool.core.io.IoUtil;
+
import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
+import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -765,7 +768,7 @@ public class FileUtils {
public static boolean SaveFileAs(String content, String path) {
FileWriter fw = null;
try {
- fw = new FileWriter(new File(path), false);
+ fw = new FileWriter(path, Charset.forName("UTF8"));
if (content != null) {
fw.write(content);
}
@@ -949,6 +952,7 @@ public class FileUtils {
public static String readFileAll(String fileName) {
String encoding = "UTF-8";
File file = new File(fileName);
+
Long filelength = file.length();
byte[] filecontent = new byte[filelength.intValue()];
try {
diff --git a/api-admin/src/main/java/com/glxp/sale/admin/util/GennerOrderUtils.java b/api-admin/src/main/java/com/glxp/sale/admin/util/GennerOrderUtils.java
new file mode 100644
index 0000000..f878464
--- /dev/null
+++ b/api-admin/src/main/java/com/glxp/sale/admin/util/GennerOrderUtils.java
@@ -0,0 +1,220 @@
+package com.glxp.sale.admin.util;
+
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Random;
+
+@Service
+public class GennerOrderUtils {
+
+ @Resource
+ RedisUtil redisUtil;
+
+ /**
+ * 生成单号前缀
+ */
+ private static String getFormNoPrefix(OrderNoTypeBean orderNoTypeEnum) {
+ //格式化时间
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern(orderNoTypeEnum.getDatePattern());
+ StringBuffer sb = new StringBuffer();
+ sb.append(orderNoTypeEnum.getPrefix());
+ sb.append(formatter.format(LocalDateTime.now()));
+ return sb.toString();
+ }
+
+ /**
+ * 构建流水号缓存Key
+ *
+ * @param serialPrefix 流水号前缀
+ * @return 流水号缓存Key
+ */
+ private static String getStCacheKey(String serialPrefix) {
+ return Constant.SERIAL_CACHE_PREFIX_ST.concat(serialPrefix);
+ }
+
+ private static String getScCacheKey(String serialPrefix) {
+ return Constant.SERIAL_CACHE_PREFIX.concat(serialPrefix);
+ }
+
+ private static String getSyncUdiCacheKey(String serialPrefix) {
+ return Constant.SERIAL_CACHE_SYNC_UDI.concat(serialPrefix);
+ }
+
+
+ /**
+ * 补全流水号
+ *
+ * @param serialPrefix 单号前缀
+ * @param incrementalSerial 当天自增流水号
+ * @author mengqiang
+ * @date 2019/1/1
+ */
+ private static String completionSerial(String serialPrefix, Long incrementalSerial,
+ OrderNoTypeBean orderNoTypeEnum) {
+ StringBuffer sb = new StringBuffer(serialPrefix);
+
+ //需要补0的长度=流水号长度 -当日自增计数长度
+ int length = orderNoTypeEnum.getSerialLength() - String.valueOf(incrementalSerial).length();
+ //补零
+ for (int i = 0; i < length; i++) {
+ sb.append("0");
+ }
+ //redis当日自增数
+ sb.append(incrementalSerial);
+ return sb.toString();
+ }
+
+
+ /**
+ * 补全随机数
+ *
+ * @param serialWithPrefix 当前单号
+ * @param orderNoTypeEnum 单号生成枚举
+ * @author mengqiang
+ * @date 2019/1/1
+ */
+ private static String completionRandom(String serialWithPrefix, OrderNoTypeBean orderNoTypeEnum) {
+ StringBuilder sb = new StringBuilder(serialWithPrefix);
+ //随机数长度
+ int length = orderNoTypeEnum.getRandomLength();
+ if (length > 0) {
+ Random random = new Random();
+ for (int i = 0; i < length; i++) {
+ //十以内随机数补全
+ sb.append(random.nextInt(10));
+ }
+ }
+ return sb.toString();
+ }
+
+ /**
+ * @param orderNoTypeEnum:
+ * @Description 基于redis生成单号(时间格式 + 自增数)
+ * @author wangliangzhi
+ * @Date: 2021/12/21
+ * @time: 14:15
+ * @return: java.lang.String
+ **/
+ public String createScOrderNo(OrderNoTypeBean orderNoTypeEnum) {
+ //获得单号前缀
+ //格式 固定前缀 +时间前缀 示例
+ String formNoPrefix = getFormNoPrefix(orderNoTypeEnum);
+ //获得缓存key
+ String cacheKey = getScCacheKey(formNoPrefix);
+ //获得当日自增数
+ Long incrementalSerial = redisUtil.incr(cacheKey, 1);
+ // 设置key过期时间, 保证每天的流水号从1开始
+ if (incrementalSerial == 1) {
+ //设置失效时间 凌晨过期
+ redisUtil.expire(cacheKey, getSecondsNextEarlyMorning());
+ }
+ //组合单号并补全流水号
+ String serialWithPrefix = completionSerial(formNoPrefix, incrementalSerial, orderNoTypeEnum);
+ //补全随机数
+ return completionRandom(serialWithPrefix, orderNoTypeEnum);
+ }
+
+ public String createStOrderNo(OrderNoTypeBean orderNoTypeEnum) {
+ //获得单号前缀
+ //格式 固定前缀 +时间前缀 示例
+ String formNoPrefix = getFormNoPrefix(orderNoTypeEnum);
+ //获得缓存key
+ String cacheKey = getStCacheKey(formNoPrefix);
+ //获得当日自增数
+ Long incrementalSerial = redisUtil.incr(cacheKey, 1);
+ // 设置key过期时间, 保证每天的流水号从1开始
+ if (incrementalSerial == 1) {
+ //设置失效时间 凌晨过期
+ redisUtil.expire(cacheKey, getSecondsNextEarlyMorning());
+ }
+ //组合单号并补全流水号
+ String serialWithPrefix = completionSerial(formNoPrefix, incrementalSerial, orderNoTypeEnum);
+ //补全随机数
+ return completionRandom(serialWithPrefix, orderNoTypeEnum);
+ }
+
+
+ public String createSyncUdiNo(OrderNoTypeBean orderNoTypeEnum) {
+ //获得单号前缀
+ //格式 固定前缀 +时间前缀 示例
+ String formNoPrefix = getFormNoPrefix(orderNoTypeEnum);
+ //获得缓存key
+ String cacheKey = getSyncUdiCacheKey(formNoPrefix);
+ //获得当日自增数
+ Long incrementalSerial = redisUtil.incr(cacheKey, 1);
+ // 设置key过期时间, 保证每天的流水号从1开始
+ if (incrementalSerial == 1) {
+ //设置失效时间 凌晨过期
+ redisUtil.expire(cacheKey, getSecondsNextEarlyMorning());
+ }
+ //组合单号并补全流水号
+ String serialWithPrefix = completionSerial(formNoPrefix, incrementalSerial, orderNoTypeEnum);
+ //补全随机数
+ return completionRandom(serialWithPrefix, orderNoTypeEnum);
+ }
+
+
+ private Long getSecondsNextEarlyMorning() {
+ Calendar cal = Calendar.getInstance();
+ cal.add(Calendar.DAY_OF_YEAR, 1);
+ // 改成这样就好了
+ cal.set(Calendar.HOUR_OF_DAY, 0);
+ cal.set(Calendar.SECOND, 0);
+ cal.set(Calendar.MINUTE, 0);
+ cal.set(Calendar.MILLISECOND, 0);
+ return (cal.getTimeInMillis() - System.currentTimeMillis()) / 1000;
+ }
+
+ public long getRelId() {
+ Long incrementalSerial = redisUtil.incr("udiRelId", 1);
+ if (incrementalSerial == 1) {
+ redisUtil.expire("udiRelId", getSecondsNextEarlyMorning());
+ }
+ String curTime = System.currentTimeMillis() + "";
+ return Long.parseLong(curTime.substring(1, curTime.length() - 3)) + incrementalSerial;
+ }
+
+
+ public String getSyncUdi() {
+ String date = DateUtil.formatDate(new Date(), "yyyyMMdd");
+ Long incrementalSerial = redisUtil.incr("serial_SyncUdi", 1);
+ if (incrementalSerial == 1) {
+ redisUtil.expire("serial_SyncUdi", getSecondsNextEarlyMorning());
+ }
+ return "UdiPrdoucts" + date + incrementalSerial;
+ }
+
+
+ public String getBusType() {
+ String date = DateUtil.formatDate(new Date(), "yyyyMMdd");
+ Long incrementalSerial = redisUtil.incr("serial_BusType", 1);
+ if (incrementalSerial == 1) {
+ redisUtil.expire("serial_BusType", getSecondsNextEarlyMorning());
+ }
+ return "BusType" + date + incrementalSerial;
+ }
+
+ public String getOrders() {
+ String date = DateUtil.formatDate(new Date(), "yyyyMMdd");
+ Long incrementalSerial = redisUtil.incr("serial_Orders", 1);
+ if (incrementalSerial == 1) {
+ redisUtil.expire("serial_Orders", getSecondsNextEarlyMorning());
+ }
+ return "Orders" + date + incrementalSerial;
+ }
+
+ public String getAllProducts() {
+ String date = DateUtil.formatDate(new Date(), "yyyyMMdd");
+ Long incrementalSerial = redisUtil.incr("serial_AllProducts", 1);
+ if (incrementalSerial == 1) {
+ redisUtil.expire("serial_AllProducts", getSecondsNextEarlyMorning());
+ }
+ return "AllProducts" + date + incrementalSerial;
+ }
+
+}
diff --git a/api-admin/src/main/java/com/glxp/sale/admin/util/OrderNoTypeBean.java b/api-admin/src/main/java/com/glxp/sale/admin/util/OrderNoTypeBean.java
new file mode 100644
index 0000000..f104556
--- /dev/null
+++ b/api-admin/src/main/java/com/glxp/sale/admin/util/OrderNoTypeBean.java
@@ -0,0 +1,45 @@
+package com.glxp.sale.admin.util;
+
+import lombok.Data;
+
+@Data
+public class OrderNoTypeBean {
+
+ private String prefix;
+
+ /**
+ * 时间格式表达式
+ * 例如:yyyyMMdd
+ */
+ private String datePattern;
+
+ /**
+ * 流水号长度 --指的是自增的顺序
+ */
+ private Integer serialLength;
+ /**
+ * 随机数长度 --指的是使用随机生成的数字
+ */
+ private Integer randomLength;
+
+ /**
+ * 总长度
+ */
+ private Integer totalLength;
+
+ public OrderNoTypeBean(String prefix, String datePattern, Integer serialLength, Integer randomLength, Integer totalLength) {
+ this.prefix = prefix;
+ this.datePattern = datePattern;
+ this.serialLength = serialLength;
+ this.randomLength = randomLength;
+ this.totalLength = totalLength;
+ }
+
+ public OrderNoTypeBean(String prefix, String datePattern) {
+ this.prefix = prefix;
+ this.datePattern = datePattern;
+ this.serialLength = 4;
+ this.randomLength = 0;
+ this.totalLength = 5;
+ }
+}
diff --git a/api-admin/src/main/resources/mybatis/mapper/sync/BasicExportDao.xml b/api-admin/src/main/resources/mybatis/mapper/sync/BasicExportDao.xml
index 7e7ea76..670f3cc 100644
--- a/api-admin/src/main/resources/mybatis/mapper/sync/BasicExportDao.xml
+++ b/api-admin/src/main/resources/mybatis/mapper/sync/BasicExportDao.xml
@@ -27,7 +27,7 @@
replace
- INTO basic_export_status(id,taskId,idDatas,status,`type`,transportType,updateTime,scheduleType,startTime,endTime,remark,superiorService,subordinateService)
+ INTO basic_export_status(id,taskId,idDatas,status,`type`,transportType,updateTime,scheduleType,startTime,endTime,remark,superiorService,subordinateService,cacheFilePath)
values(
#{id},
#{taskId},
@@ -41,7 +41,8 @@
#{endTime},
#{remark},
#{superiorService},
- #{subordinateService}
+ #{subordinateService},
+ #{cacheFilePath}
)
@@ -60,6 +61,7 @@
remark=#{remark},
superiorService=#{superiorService},
subordinateService=#{subordinateService},
+ cacheFilePath=#{cacheFilePath},
WHERE id = #{id}
diff --git a/api-admin/src/main/resources/mybatis/mapper/sync/BasicUploadDao.xml b/api-admin/src/main/resources/mybatis/mapper/sync/BasicUploadDao.xml
index 8ddb8aa..f319f22 100644
--- a/api-admin/src/main/resources/mybatis/mapper/sync/BasicUploadDao.xml
+++ b/api-admin/src/main/resources/mybatis/mapper/sync/BasicUploadDao.xml
@@ -34,7 +34,8 @@
replace
- INTO basic_upload_status(id,taskId,idDatas,status,type,transportType,updateTime,scheduleType,startTime,endTime,remark,superiorService,subordinateService)
+ INTO basic_upload_status(id,taskId,idDatas,status,type,transportType,
+ updateTime,scheduleType,startTime,endTime,remark,superiorService,subordinateService,cacheFilePath)
values(
#{id},
#{taskId},
@@ -48,7 +49,7 @@
#{endTime},
#{remark},
#{superiorService},
- #{subordinateService}
+ #{subordinateService},#{cacheFilePath}
)
@@ -66,6 +67,8 @@
remark=#{remark},
subordinateService=#{subordinateService},
superiorService=#{superiorService},
+ cacheFilePath=#{cacheFilePath},
+
WHERE id = #{id}