bug修复,网络断开情况下修改

version1
anthonyywj2 3 years ago
parent 8fcaebcca2
commit bcf3945643

@ -352,6 +352,14 @@
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
</plugins>
</build>

@ -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<SpSyncUdiResponse>() {
});

@ -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 {
//上游通

@ -23,4 +23,5 @@ public class BasicExportStatusEntity {
private String remark;
private String superiorService; //上游服务
private String subordinateService; //下游服务
private String cacheFilePath;
}

@ -25,4 +25,6 @@ public class BasicUploadStatusEntity {
private String remark;
private String superiorService; //上游服务
private String subordinateService; //下游服务
private String cacheFilePath;
}

@ -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);
}

@ -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<ProductInfoEntity> productInfoEntityList;
List<UdiCompanyEntity> 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();
}
}

@ -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();
}

@ -27,7 +27,7 @@ public class BasicExportServiceImpl implements BasicExportService {
basicExportStatusRequest.setId(id);
List<BasicExportStatusEntity> basicExportStatusEntities = basicExportDao.filterExportStatus(basicExportStatusRequest);
if (CollUtil.isNotEmpty(basicExportStatusEntities)) {
basicExportStatusEntities.get(0);
return basicExportStatusEntities.get(0);
}
return null;
}

@ -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<SpSyncUdiResponse> 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());

@ -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<SpsSyncDataResponse>() {
});
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<SpsSyncDataResponse>() {
});
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<SpsSyncBusResponse>() {
});
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<SpsSyncBusResponse>() {
});
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<SpsSyncOrderResponse>() {
});
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<SpsSyncOrderResponse>() {
});
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<SpsSyncScheduleResponse>() {
});
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<SpSyncUdiResponse>() {
});
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<SpsSyncOrderResponse>() {
});
redisUtil.set(fileName, baseResponse);
try {
FileUtils.CutFile(file.getPath(), getPath() + FileConstant.waitDownload_products_back + file.getName());
} catch (Exception e) {

@ -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<String> 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<String> 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<String> 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<String> 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<String> 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<String> 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);
}
}
}

@ -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; //等待下游下载
}

@ -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 {

@ -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;
}
}

@ -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;
}
}

@ -27,7 +27,7 @@
<insert id="insertExportStatus" keyProperty="id"
parameterType="com.glxp.sale.admin.entity.sync.BasicExportStatusEntity">
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}
)
</insert>
@ -60,6 +61,7 @@
<if test="remark != null">remark=#{remark},</if>
<if test="superiorService != null">superiorService=#{superiorService},</if>
<if test="subordinateService != null">subordinateService=#{subordinateService},</if>
<if test="cacheFilePath != null">cacheFilePath=#{cacheFilePath},</if>
</trim>
WHERE id = #{id}
</update>

@ -34,7 +34,8 @@
<insert id="insertUploadStatus" keyProperty="id"
parameterType="com.glxp.sale.admin.entity.sync.BasicUploadStatusEntity">
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}
)
</insert>
@ -66,6 +67,8 @@
<if test="remark != null">remark=#{remark},</if>
<if test="subordinateService != null">subordinateService=#{subordinateService},</if>
<if test="superiorService != null">superiorService=#{superiorService},</if>
<if test="cacheFilePath != null">cacheFilePath=#{cacheFilePath},</if>
</trim>
WHERE id = #{id}
</update>

Loading…
Cancel
Save