|
|
|
|
package com.glxp.api.service.sync;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
import com.glxp.api.common.res.BaseResponse;
|
|
|
|
|
import com.glxp.api.common.util.ResultVOUtils;
|
|
|
|
|
import com.glxp.api.constant.*;
|
|
|
|
|
import com.glxp.api.dao.basic.BasicProductsDao;
|
|
|
|
|
import com.glxp.api.entity.basic.*;
|
|
|
|
|
import com.glxp.api.entity.inout.*;
|
|
|
|
|
import com.glxp.api.entity.purchase.*;
|
|
|
|
|
import com.glxp.api.entity.sync.BasicExportStatusEntity;
|
|
|
|
|
import com.glxp.api.entity.sync.BasicExportStatusTimeEntity;
|
|
|
|
|
import com.glxp.api.entity.sync.SyncDataBustypeEntity;
|
|
|
|
|
import com.glxp.api.req.basic.ProductInfoFilterRequest;
|
|
|
|
|
import com.glxp.api.req.basic.UdiCompanyRequest;
|
|
|
|
|
import com.glxp.api.req.inout.FilterOrderRequest;
|
|
|
|
|
import com.glxp.api.req.sync.SpsSyncDataRequest;
|
|
|
|
|
import com.glxp.api.res.sync.SpSyncUdiResponse;
|
|
|
|
|
import com.glxp.api.res.sync.SpsSyncOrderResponse;
|
|
|
|
|
import com.glxp.api.res.system.SyncDataSetResponse;
|
|
|
|
|
import com.glxp.api.service.basic.*;
|
|
|
|
|
import com.glxp.api.service.inout.*;
|
|
|
|
|
import com.glxp.api.service.purchase.*;
|
|
|
|
|
import com.glxp.api.util.CustomUtil;
|
|
|
|
|
import com.glxp.api.util.DateUtil;
|
|
|
|
|
import com.glxp.api.util.JsonUtils;
|
|
|
|
|
import com.glxp.api.util.RedisUtil;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.context.ApplicationContext;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.FileWriter;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.function.Function;
|
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
|
@Service
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
|
public class SpsSyncDownloadService {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final Logger logger = LoggerFactory.getLogger(SpsSyncDownloadService.class);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final RedisUtil redisUtil;
|
|
|
|
|
|
|
|
|
|
//已完成扫码单据
|
|
|
|
|
@Resource
|
|
|
|
|
IoOrderService orderService;
|
|
|
|
|
@Resource
|
|
|
|
|
IoCodeService codesService;
|
|
|
|
|
@Resource
|
|
|
|
|
SyncDataSetService syncDataSetService;
|
|
|
|
|
@Resource
|
|
|
|
|
IoOrderDetailBizService orderDetailBizService;
|
|
|
|
|
@Resource
|
|
|
|
|
IoOrderDetailCodeService orderDetailCodeService;
|
|
|
|
|
@Resource
|
|
|
|
|
IoOrderDetailResultService orderDetailResultService;
|
|
|
|
|
@Resource
|
|
|
|
|
BasicExportService basicExportService;
|
|
|
|
|
@Resource
|
|
|
|
|
BasicExportTimeService basicExportTimeService;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
IoOrderInvoiceService orderInvoiceService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 创建单据同步任务
|
|
|
|
|
public void syncOrderTask() {
|
|
|
|
|
|
|
|
|
|
log.info("创建单据同步任务");
|
|
|
|
|
//自动创建要求被下载已完成单据任务.
|
|
|
|
|
// 1.判断是否同步任务已存在
|
|
|
|
|
BasicExportStatusEntity basicExportStatusEntity1 = basicExportService.findByData(ConstantStatus.SYNC_SCAN_ORDER, 1);
|
|
|
|
|
if (basicExportStatusEntity1 == null) {
|
|
|
|
|
|
|
|
|
|
BaseResponse<SpsSyncOrderResponse> baseResponse = findOrder(getRequest(ConstantStatus.SYNC_SCAN_ORDER));
|
|
|
|
|
SpsSyncOrderResponse syncOrderResponse = baseResponse.getData();
|
|
|
|
|
// 2.查看是否有需要更新的数据
|
|
|
|
|
if (CollUtil.isNotEmpty(syncOrderResponse.getOrderEntities())) {
|
|
|
|
|
// 3.插入到任务表,等待获取
|
|
|
|
|
BasicExportStatusEntity orderStatusEntity = new BasicExportStatusEntity();
|
|
|
|
|
orderStatusEntity.setId(CustomUtil.getId());
|
|
|
|
|
orderStatusEntity.setIdDatas(ConstantStatus.SYNC_SCAN_ORDER);
|
|
|
|
|
orderStatusEntity.setType(BasicProcessStatus.NEW_ALL_ORDER);
|
|
|
|
|
orderStatusEntity.setUpdateTime(new Date());
|
|
|
|
|
orderStatusEntity.setStatus(0);
|
|
|
|
|
orderStatusEntity.setStartTime(new Date());
|
|
|
|
|
orderStatusEntity.setScheduleType(BasicProcessStatus.SCHEDULE_NORMAL);
|
|
|
|
|
basicExportService.insertExportStatus(orderStatusEntity);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 创建国家库同步任务
|
|
|
|
|
public void syncDiProductsTask() {
|
|
|
|
|
BasicExportStatusEntity basicExportStatusEntity4 = basicExportService.findByData(ConstantStatus.SYNC_DI_PRODUCTS, 1);
|
|
|
|
|
if (basicExportStatusEntity4 == null) {
|
|
|
|
|
BaseResponse<SpSyncUdiResponse> baseResponse = syncUdi(getRequest(ConstantStatus.SYNC_DI_PRODUCTS));
|
|
|
|
|
SpSyncUdiResponse spSyncUdiResponse = baseResponse.getData();
|
|
|
|
|
if (CollUtil.isNotEmpty(spSyncUdiResponse.getProductInfoEntityList())
|
|
|
|
|
|| CollUtil.isNotEmpty(spSyncUdiResponse.getUdiCompanyEntities())) {
|
|
|
|
|
BasicExportStatusEntity basicExportStatusEntity = new BasicExportStatusEntity();
|
|
|
|
|
basicExportStatusEntity.setId(CustomUtil.getId());
|
|
|
|
|
basicExportStatusEntity.setIdDatas(ConstantStatus.SYNC_DI_PRODUCTS);
|
|
|
|
|
basicExportStatusEntity.setType(BasicExportTypeEnum.COUNTRY_DI_DATA.getRemark());
|
|
|
|
|
basicExportStatusEntity.setUpdateTime(new Date());
|
|
|
|
|
basicExportStatusEntity.setStartTime(new Date());
|
|
|
|
|
basicExportStatusEntity.setStatus(BasicExportStatusEnum.WAIT_TRIGGERED.getCode());
|
|
|
|
|
basicExportStatusEntity.setScheduleType(BasicProcessStatus.SCHEDULE_NORMAL);
|
|
|
|
|
basicExportService.insertExportStatus(basicExportStatusEntity);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final BasicHospTypeService hospTypeService;
|
|
|
|
|
|
|
|
|
|
private final UdiRelevanceService udiRelevanceService;
|
|
|
|
|
|
|
|
|
|
private final BasicProductsDao basicProductsDao;
|
|
|
|
|
|
|
|
|
|
private final CompanyProductRelevanceService relevanceService;
|
|
|
|
|
|
|
|
|
|
private final BasicCorpService corpService;
|
|
|
|
|
|
|
|
|
|
private final SupCertService supCertService;
|
|
|
|
|
|
|
|
|
|
private final SupCertSetService supCertSetService;
|
|
|
|
|
|
|
|
|
|
private final SupCompanyService supCompanyService;
|
|
|
|
|
|
|
|
|
|
private final SupManufacturerService supManufacturerService;
|
|
|
|
|
|
|
|
|
|
private final SupProductService supProductService;
|
|
|
|
|
|
|
|
|
|
@Value("${file_path}")
|
|
|
|
|
private String filePath;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 同步数据
|
|
|
|
|
*
|
|
|
|
|
* @param info 同步设置
|
|
|
|
|
* @param exportType 数据模块类型
|
|
|
|
|
*/
|
|
|
|
|
public void syncData(SyncDataSetResponse info, BasicExportTypeEnum exportType) {
|
|
|
|
|
Date now = new Date();
|
|
|
|
|
switch (exportType) {
|
|
|
|
|
case BASIC_DATA:
|
|
|
|
|
if (needExec(info.getBasicProducts(), info.getBasicCorp(), info.getSupCert())) {
|
|
|
|
|
basicExportInfoCreate(exportType, now
|
|
|
|
|
, x -> x.generateBasicDataFile(info, now, false)
|
|
|
|
|
, x -> x.generateBasicDataFile(info, now, true));
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case OTHER_DATA:
|
|
|
|
|
if (needExec(info.getUdiCodeLost(), info.getUdiCodeRel())) {
|
|
|
|
|
basicExportInfoCreate(exportType, now
|
|
|
|
|
, x -> x.generateOtherDataFile(info, now, false)
|
|
|
|
|
, x -> x.generateOtherDataFile(info, now, true));
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case COUNTRY_DI_DATA:
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 同步基础数据模块
|
|
|
|
|
*
|
|
|
|
|
* @param info 同步设置
|
|
|
|
|
*/
|
|
|
|
|
public void syncBasicData(SyncDataSetResponse info) {
|
|
|
|
|
|
|
|
|
|
Date now = new Date();
|
|
|
|
|
//是否需要执行
|
|
|
|
|
boolean needExec = info.getBasicProducts() == 2 || info.getBasicCorp() == 2 || info.getSupCert() == 2;
|
|
|
|
|
if (!needExec) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
basicExportInfoCreate(BasicExportTypeEnum.BASIC_DATA, now
|
|
|
|
|
, x -> x.generateBasicDataFile(info, now, false)
|
|
|
|
|
, x -> x.generateBasicDataFile(info, now, true));
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 同步其他模块
|
|
|
|
|
*
|
|
|
|
|
* @param info 同步设置
|
|
|
|
|
*/
|
|
|
|
|
public void syncOtherData(SyncDataSetResponse info) {
|
|
|
|
|
|
|
|
|
|
Date now = new Date();
|
|
|
|
|
//是否需要执行
|
|
|
|
|
boolean needExec = info.getUdiCodeLost() == 2 || info.getUdiCodeRel() == 2;
|
|
|
|
|
if (!needExec) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
basicExportInfoCreate(BasicExportTypeEnum.OTHER_DATA, now
|
|
|
|
|
, x -> x.generateOtherDataFile(info, now, false)
|
|
|
|
|
, x -> x.generateOtherDataFile(info, now, true));
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 判断是否需要执行
|
|
|
|
|
*
|
|
|
|
|
* @param set 需要判断的数据
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private boolean needExec(int... set) {
|
|
|
|
|
|
|
|
|
|
return Arrays.stream(set).filter(i -> i == 2).findAny().isPresent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private final ApplicationContext applicationContext;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 创建一个同步任务
|
|
|
|
|
*
|
|
|
|
|
* @param exportEnum 任务类型枚举
|
|
|
|
|
* @param hasDataMethod 判断时候有无数据方法
|
|
|
|
|
* @param createFileMethod 执行文件生成方法
|
|
|
|
|
*/
|
|
|
|
|
private void basicExportInfoCreate(BasicExportTypeEnum exportEnum, Date now, Function<SpsSyncDownloadService, Boolean> hasDataMethod, Function<SpsSyncDownloadService, Boolean> createFileMethod) {
|
|
|
|
|
//防止出现同时调用问题
|
|
|
|
|
String redisKey = String.format("spsm-sync-create:%s", exportEnum.getKey());
|
|
|
|
|
boolean result = redisUtil.setIfAbsent(redisKey, 1, 10);
|
|
|
|
|
if (!result) {
|
|
|
|
|
String errorMsg = String.format("syncIdcSps----process------------同步[%s]重复进入", exportEnum.getRemark());
|
|
|
|
|
// logger.info(errorMsg);
|
|
|
|
|
throw new RuntimeException(errorMsg);
|
|
|
|
|
}
|
|
|
|
|
BasicExportStatusEntity exportStatus = basicExportService.getOne(Wrappers.lambdaQuery(BasicExportStatusEntity.class)
|
|
|
|
|
.eq(BasicExportStatusEntity::getType, BasicExportTypeEnum.BASIC_DATA.getRemark())
|
|
|
|
|
.orderByDesc(BasicExportStatusEntity::getStartTime)
|
|
|
|
|
.last("limit 1")
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
//首次任务or上次任务结束
|
|
|
|
|
if (exportStatus == null || BasicExportStatusEnum.COMPLETED.getCode().equals(exportStatus.getStatus())) {
|
|
|
|
|
|
|
|
|
|
//判断有无新数据
|
|
|
|
|
Boolean hasData = hasDataMethod.apply(applicationContext.getBean(this.getClass()));
|
|
|
|
|
if (Boolean.FALSE.equals(hasData)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
exportStatus = BasicExportStatusEntity.builder()
|
|
|
|
|
.id(CustomUtil.getId())
|
|
|
|
|
.status(BasicExportStatusEnum.WAIT_TRIGGERED.getCode())
|
|
|
|
|
.idDatas(BasicExportTypeEnum.BASIC_DATA.getKey())
|
|
|
|
|
.type(BasicExportTypeEnum.BASIC_DATA.getRemark())
|
|
|
|
|
.scheduleType(0)
|
|
|
|
|
.updateTime(cn.hutool.core.date.DateUtil.date())
|
|
|
|
|
.startTime(now)
|
|
|
|
|
.build();
|
|
|
|
|
basicExportService.save(exportStatus);
|
|
|
|
|
} else if (exportStatus.getStatus().equals(BasicExportStatusEnum.WAIT_BUILT.getCode())) {//文件待生成
|
|
|
|
|
createFileMethod.apply(applicationContext.getBean(this.getClass()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 读取基础数据,创建文件
|
|
|
|
|
*
|
|
|
|
|
* @param info 同步设置信息
|
|
|
|
|
* @param now 当前时间
|
|
|
|
|
* @param createFile 是否创建文件
|
|
|
|
|
* @return 是否有数据 true/false 有新数据/无新数据
|
|
|
|
|
*/
|
|
|
|
|
protected boolean generateBasicDataFile(SyncDataSetResponse info, Date now, boolean createFile) {
|
|
|
|
|
//文件数据
|
|
|
|
|
Map<String, List> jsonMap = new WeakHashMap<>(4);
|
|
|
|
|
Map<BasicExportStatusTimeEnum, Map<String, Object>> totalTimeMap = new WeakHashMap<>(10);
|
|
|
|
|
try {
|
|
|
|
|
//确认有开启物资字典由外向内同步
|
|
|
|
|
if (needExec(info.getBasicProducts())) {
|
|
|
|
|
Map<String, Object> map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.BASIC_PRODUCTS, createFile);
|
|
|
|
|
totalTimeMap.put(BasicExportStatusTimeEnum.BASIC_PRODUCTS, map);
|
|
|
|
|
List<BasicHospTypeEntity> hospTypeList = hospTypeService.list(Wrappers.lambdaQuery(BasicHospTypeEntity.class)
|
|
|
|
|
.le((boolean) map.get("isNew"), BasicHospTypeEntity::getUpdateTime, now)
|
|
|
|
|
.between(!(boolean) map.get("isNew"), BasicHospTypeEntity::getUpdateTime
|
|
|
|
|
, map.get("oldDate"), now)
|
|
|
|
|
);
|
|
|
|
|
if (CollectionUtil.isNotEmpty(hospTypeList)) {
|
|
|
|
|
jsonMap.put(BasicExportStatusTimeEntity.class.getSimpleName(), hospTypeList);
|
|
|
|
|
}
|
|
|
|
|
List<UdiRelevanceEntity> udiRelevanceList = udiRelevanceService.list(Wrappers.lambdaQuery(UdiRelevanceEntity.class)
|
|
|
|
|
.le((boolean) map.get("isNew"), UdiRelevanceEntity::getUpdateTime, now)
|
|
|
|
|
.between(!(boolean) map.get("isNew"), UdiRelevanceEntity::getUpdateTime
|
|
|
|
|
, map.get("oldDate"), now)
|
|
|
|
|
);
|
|
|
|
|
if (CollectionUtil.isNotEmpty(udiRelevanceList)) {
|
|
|
|
|
jsonMap.put(UdiRelevanceEntity.class.getSimpleName(), udiRelevanceList);
|
|
|
|
|
}
|
|
|
|
|
List<BasicProductsEntity> productsList = basicProductsDao.selectList(Wrappers.lambdaQuery(BasicProductsEntity.class)
|
|
|
|
|
.le((boolean) map.get("isNew"), BasicProductsEntity::getUpdateTime, now)
|
|
|
|
|
.between(!(boolean) map.get("isNew"), BasicProductsEntity::getUpdateTime
|
|
|
|
|
, map.get("oldDate"), now)
|
|
|
|
|
);
|
|
|
|
|
if (CollectionUtil.isNotEmpty(productsList)) {
|
|
|
|
|
jsonMap.put(BasicProductsEntity.class.getSimpleName(), productsList);
|
|
|
|
|
}
|
|
|
|
|
List<CompanyProductRelevanceEntity> relevanceList = relevanceService.list(Wrappers.lambdaQuery(CompanyProductRelevanceEntity.class)
|
|
|
|
|
.le((boolean) map.get("isNew"), CompanyProductRelevanceEntity::getUpdateTime, now)
|
|
|
|
|
.between(!(boolean) map.get("isNew"), CompanyProductRelevanceEntity::getUpdateTime
|
|
|
|
|
, map.get("oldDate"), now)
|
|
|
|
|
);
|
|
|
|
|
if (CollectionUtil.isNotEmpty(relevanceList)) {
|
|
|
|
|
jsonMap.put(CompanyProductRelevanceEntity.class.getSimpleName(), relevanceList);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//确认有开启往来单位字典同步
|
|
|
|
|
if (needExec(info.getBasicCorp())) {
|
|
|
|
|
Map<String, Object> map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.BASIC_CORP, createFile);
|
|
|
|
|
totalTimeMap.put(BasicExportStatusTimeEnum.BASIC_CORP, map);
|
|
|
|
|
List<BasicCorpEntity> corpList = corpService.list(Wrappers.lambdaQuery(BasicCorpEntity.class)
|
|
|
|
|
.le((boolean) map.get("isNew"), BasicCorpEntity::getUpdateTime, now)
|
|
|
|
|
.between(!(boolean) map.get("isNew"), BasicCorpEntity::getUpdateTime
|
|
|
|
|
, map.get("oldDate"), now)
|
|
|
|
|
);
|
|
|
|
|
if (CollectionUtil.isNotEmpty(corpList)) {
|
|
|
|
|
jsonMap.put(BasicCorpEntity.class.getSimpleName(), corpList);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//确认有开启首营资质同步
|
|
|
|
|
if (needExec(info.getSupCert())) {
|
|
|
|
|
Map<String, Object> map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.SUP_CERT, createFile);
|
|
|
|
|
totalTimeMap.put(BasicExportStatusTimeEnum.SUP_CERT, map);
|
|
|
|
|
List<SupCertEntity> supCertList = supCertService.list(Wrappers.lambdaQuery(SupCertEntity.class)
|
|
|
|
|
.le((boolean) map.get("isNew"), SupCertEntity::getUpdateTime, now)
|
|
|
|
|
.between(!(boolean) map.get("isNew"), SupCertEntity::getUpdateTime
|
|
|
|
|
, map.get("oldDate"), now)
|
|
|
|
|
);
|
|
|
|
|
if (CollectionUtil.isNotEmpty(supCertList)) {
|
|
|
|
|
jsonMap.put(SupCertEntity.class.getSimpleName(), supCertList);
|
|
|
|
|
}
|
|
|
|
|
List<SupCertSetEntity> supCertSetList = supCertSetService.list(Wrappers.lambdaQuery(SupCertSetEntity.class)
|
|
|
|
|
.le((boolean) map.get("isNew"), SupCertSetEntity::getUpdateTime, now)
|
|
|
|
|
.between(!(boolean) map.get("isNew"), SupCertSetEntity::getUpdateTime
|
|
|
|
|
, map.get("oldDate"), now)
|
|
|
|
|
);
|
|
|
|
|
if (CollectionUtil.isNotEmpty(supCertSetList)) {
|
|
|
|
|
jsonMap.put(SupCertSetEntity.class.getSimpleName(), supCertSetList);
|
|
|
|
|
}
|
|
|
|
|
List<SupCompanyEntity> supCompanyList = supCompanyService.list(Wrappers.lambdaQuery(SupCompanyEntity.class)
|
|
|
|
|
.le((boolean) map.get("isNew"), SupCompanyEntity::getUpdateTime, now)
|
|
|
|
|
.between(!(boolean) map.get("isNew"), SupCompanyEntity::getUpdateTime
|
|
|
|
|
, map.get("oldDate"), now)
|
|
|
|
|
);
|
|
|
|
|
if (CollectionUtil.isNotEmpty(supCompanyList)) {
|
|
|
|
|
jsonMap.put(SupCompanyEntity.class.getSimpleName(), supCompanyList);
|
|
|
|
|
}
|
|
|
|
|
List<SupManufacturerEntity> supManufacturerList = supManufacturerService.list(Wrappers.lambdaQuery(SupManufacturerEntity.class)
|
|
|
|
|
.le((boolean) map.get("isNew"), SupManufacturerEntity::getUpdateTime, now)
|
|
|
|
|
.between(!(boolean) map.get("isNew"), SupManufacturerEntity::getUpdateTime
|
|
|
|
|
, map.get("oldDate"), now)
|
|
|
|
|
);
|
|
|
|
|
if (CollectionUtil.isNotEmpty(supManufacturerList)) {
|
|
|
|
|
jsonMap.put(SupManufacturerEntity.class.getSimpleName(), supManufacturerList);
|
|
|
|
|
}
|
|
|
|
|
List<SupProductEntity> supProductList = supProductService.list(Wrappers.lambdaQuery(SupProductEntity.class)
|
|
|
|
|
.le((boolean) map.get("isNew"), SupProductEntity::getUpdateTime, now)
|
|
|
|
|
.between(!(boolean) map.get("isNew"), SupProductEntity::getUpdateTime
|
|
|
|
|
, map.get("oldDate"), now)
|
|
|
|
|
);
|
|
|
|
|
if (CollectionUtil.isNotEmpty(supProductList)) {
|
|
|
|
|
jsonMap.put(SupProductEntity.class.getSimpleName(), supProductList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (jsonMap.size() > 0) {
|
|
|
|
|
if (!createFile) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
String fileFullPath = writeFile(filePath, BasicExportTypeEnum.BASIC_DATA.getRemark(), JsonUtils.toJsonString(jsonMap));
|
|
|
|
|
//计算总数
|
|
|
|
|
int total = 0;
|
|
|
|
|
for (List l : jsonMap.values()) {
|
|
|
|
|
total += l.size();
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
//修改任务数据
|
|
|
|
|
boolean update = basicExportService.update(Wrappers.lambdaUpdate(BasicExportStatusEntity.class)
|
|
|
|
|
.set(BasicExportStatusEntity::getStatus, BasicExportStatusEnum.WAIT_SYNC.getCode())
|
|
|
|
|
.set(BasicExportStatusEntity::getUpdateTime, new Date())
|
|
|
|
|
.set(BasicExportStatusEntity::getCacheFilePath, fileFullPath)
|
|
|
|
|
.set(BasicExportStatusEntity::getRemark, String.format("%s: %s条", BasicExportTypeEnum.BASIC_DATA.getRemark(), total))
|
|
|
|
|
.eq(BasicExportStatusEntity::getType, BasicExportTypeEnum.BASIC_DATA.getRemark())
|
|
|
|
|
.eq(BasicExportStatusEntity::getStatus, BasicExportStatusEnum.WAIT_BUILT.getCode())
|
|
|
|
|
.isNull(BasicExportStatusEntity::getCacheFilePath)
|
|
|
|
|
);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
// 异常回滚
|
|
|
|
|
this.exportTimeRollback(totalTimeMap, BasicExportTypeEnum.BASIC_DATA, fileFullPath);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
logger.error(String.format("syncIdcSps----process------------生成[%s]文件及更改库操作异常,异常信息<%s>"
|
|
|
|
|
, BasicExportTypeEnum.BASIC_DATA.getRemark(), e.getMessage()));
|
|
|
|
|
// 异常回滚
|
|
|
|
|
this.exportTimeRollback(totalTimeMap, BasicExportTypeEnum.BASIC_DATA, null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error(e.getMessage());
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final IoCodeLostService ioCodeLostService;
|
|
|
|
|
|
|
|
|
|
private final IoCodeRelService ioCodeRelService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 读取其他数据,创建文件
|
|
|
|
|
*
|
|
|
|
|
* @param info 同步设置信息
|
|
|
|
|
* @param now 当前时间
|
|
|
|
|
* @param createFile 是否创建文件
|
|
|
|
|
* @return 是否有数据 true/false 有新数据/无新数据
|
|
|
|
|
*/
|
|
|
|
|
protected boolean generateOtherDataFile(SyncDataSetResponse info, Date now, boolean createFile) {
|
|
|
|
|
//文件数据
|
|
|
|
|
Map<String, List> jsonMap = new WeakHashMap<>(4);
|
|
|
|
|
Map<BasicExportStatusTimeEnum, Map<String, Object>> totalTimeMap = new WeakHashMap<>(10);
|
|
|
|
|
try {
|
|
|
|
|
//确认有开启物资字典由外向内同步
|
|
|
|
|
if (info.getUdiCodeLost() == 2) {
|
|
|
|
|
Map<String, Object> map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.IO_CODE_LOST, createFile);
|
|
|
|
|
totalTimeMap.put(BasicExportStatusTimeEnum.IO_CODE_LOST, map);
|
|
|
|
|
List<IoCodeLostEntity> ioCodeLostList = ioCodeLostService.list(Wrappers.lambdaQuery(IoCodeLostEntity.class)
|
|
|
|
|
.le((boolean) map.get("isNew"), IoCodeLostEntity::getUpdateTime, now)
|
|
|
|
|
.between(!(boolean) map.get("isNew"), IoCodeLostEntity::getUpdateTime
|
|
|
|
|
, map.get("oldDate"), now)
|
|
|
|
|
);
|
|
|
|
|
if (CollectionUtil.isNotEmpty(ioCodeLostList)) {
|
|
|
|
|
jsonMap.put(BasicExportStatusTimeEntity.class.getSimpleName(), ioCodeLostList);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//确认有开启udi关联关系同步
|
|
|
|
|
if (info.getUdiCodeRel() == 2) {
|
|
|
|
|
Map<String, Object> map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.IO_CODE_REL, createFile);
|
|
|
|
|
totalTimeMap.put(BasicExportStatusTimeEnum.IO_CODE_REL, map);
|
|
|
|
|
List<IoCodeRelEntity> ioCodeRelList = ioCodeRelService.list(Wrappers.lambdaQuery(IoCodeRelEntity.class)
|
|
|
|
|
.le((boolean) map.get("isNew"), IoCodeRelEntity::getUpdateTime, now)
|
|
|
|
|
.between(!(boolean) map.get("isNew"), IoCodeRelEntity::getUpdateTime
|
|
|
|
|
, map.get("oldDate"), now)
|
|
|
|
|
);
|
|
|
|
|
if (CollectionUtil.isNotEmpty(ioCodeRelList)) {
|
|
|
|
|
jsonMap.put(IoCodeRelEntity.class.getSimpleName(), ioCodeRelList);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (jsonMap.size() > 0) {
|
|
|
|
|
if (!createFile) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
String fileFullPath = writeFile(filePath, BasicExportTypeEnum.OTHER_DATA.getRemark(), JsonUtils.toJsonString(jsonMap));
|
|
|
|
|
//计算总数
|
|
|
|
|
int total = 0;
|
|
|
|
|
for (List l : jsonMap.values()) {
|
|
|
|
|
total += l.size();
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
//修改任务数据
|
|
|
|
|
boolean update = basicExportService.update(Wrappers.lambdaUpdate(BasicExportStatusEntity.class)
|
|
|
|
|
.set(BasicExportStatusEntity::getStatus, BasicExportStatusEnum.WAIT_SYNC.getCode())
|
|
|
|
|
.set(BasicExportStatusEntity::getUpdateTime, new Date())
|
|
|
|
|
.set(BasicExportStatusEntity::getCacheFilePath, fileFullPath)
|
|
|
|
|
.set(BasicExportStatusEntity::getRemark, String.format("%s: %s条", BasicExportTypeEnum.OTHER_DATA.getRemark(), total))
|
|
|
|
|
.eq(BasicExportStatusEntity::getType, BasicExportTypeEnum.OTHER_DATA.getRemark())
|
|
|
|
|
.eq(BasicExportStatusEntity::getStatus, BasicExportStatusEnum.WAIT_BUILT.getCode())
|
|
|
|
|
.isNull(BasicExportStatusEntity::getCacheFilePath)
|
|
|
|
|
);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
// 异常回滚
|
|
|
|
|
this.exportTimeRollback(totalTimeMap, BasicExportTypeEnum.OTHER_DATA, fileFullPath);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
logger.error(String.format("syncIdcSps----process------------生成[%s]文件及更改库操作异常,异常信息<%s>"
|
|
|
|
|
, BasicExportTypeEnum.OTHER_DATA.getRemark(), e.getMessage()));
|
|
|
|
|
// 异常回滚
|
|
|
|
|
this.exportTimeRollback(totalTimeMap, BasicExportTypeEnum.OTHER_DATA, null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error(e.getMessage());
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 插入 basicExportStatusTime表
|
|
|
|
|
*
|
|
|
|
|
* @param date 当前时间
|
|
|
|
|
* @param exportStatusTimeEnum key枚举
|
|
|
|
|
* @param createFile 是否需要创建文件,false时只做查询
|
|
|
|
|
* @return 最后一次同步时间 返回值需与参数 date 比较,判断是否相等
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
private Map<String, Object> basicExportStatusTimeInfo(Date date, BasicExportStatusTimeEnum exportStatusTimeEnum, boolean createFile) throws Exception {
|
|
|
|
|
//防止出现同时调用问题
|
|
|
|
|
String redisKey = String.format("spsm-sync-task:%s", exportStatusTimeEnum.getKey());
|
|
|
|
|
boolean result = redisUtil.setIfAbsent(redisKey, 1, 10);
|
|
|
|
|
if (!result) {
|
|
|
|
|
String errorMsg = String.format("syncIdcSps----process------------同步[%s]重复进入", exportStatusTimeEnum.getRemark());
|
|
|
|
|
// logger.info(errorMsg);
|
|
|
|
|
throw new Exception(errorMsg);
|
|
|
|
|
}
|
|
|
|
|
boolean isNew = true;
|
|
|
|
|
BasicExportStatusTimeEntity timeInfo = basicExportTimeService.getOne(Wrappers.lambdaQuery(BasicExportStatusTimeEntity.class)
|
|
|
|
|
.eq(BasicExportStatusTimeEntity::getKey, exportStatusTimeEnum.getKey()));
|
|
|
|
|
if (timeInfo == null) {
|
|
|
|
|
timeInfo = BasicExportStatusTimeEntity.builder()
|
|
|
|
|
.key(exportStatusTimeEnum.getKey())
|
|
|
|
|
.lastUpdateTime(DateUtil.formatDateTime(date))
|
|
|
|
|
.remark(exportStatusTimeEnum.getRemark())
|
|
|
|
|
.build();
|
|
|
|
|
if (createFile) {
|
|
|
|
|
basicExportTimeService.save(timeInfo);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (StrUtil.isNotEmpty(timeInfo.getLastUpdateTime())) {
|
|
|
|
|
isNew = false;
|
|
|
|
|
}
|
|
|
|
|
if (createFile) {
|
|
|
|
|
basicExportTimeService.update(Wrappers.lambdaUpdate(BasicExportStatusTimeEntity.class)
|
|
|
|
|
.set(BasicExportStatusTimeEntity::getLastUpdateTime, DateUtil.formatDateTime(date))
|
|
|
|
|
.eq(BasicExportStatusTimeEntity::getKey, exportStatusTimeEnum.getKey())
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
redisUtil.del(redisKey);
|
|
|
|
|
WeakHashMap<String, Object> returnMap = new WeakHashMap<>(10);
|
|
|
|
|
returnMap.put("isNew", isNew);
|
|
|
|
|
returnMap.put("oldDate", isNew ? null : timeInfo.getLastUpdateTime());
|
|
|
|
|
returnMap.put("id", timeInfo.getId());
|
|
|
|
|
|
|
|
|
|
return returnMap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 异常回滚操作
|
|
|
|
|
*
|
|
|
|
|
* @param totalTimeMap 总的exportTime数据回滚
|
|
|
|
|
* @param delFilePath 需要删除的文件地址
|
|
|
|
|
*/
|
|
|
|
|
private void exportTimeRollback(Map<BasicExportStatusTimeEnum, Map<String, Object>> totalTimeMap, BasicExportTypeEnum exportType, String delFilePath) {
|
|
|
|
|
for (Map.Entry<BasicExportStatusTimeEnum, Map<String, Object>> entry : totalTimeMap.entrySet()) {
|
|
|
|
|
//防止出现同时调用问题
|
|
|
|
|
String redisKey = String.format("spsm-sync-rollback:%s", entry.getKey().getKey());
|
|
|
|
|
boolean result = redisUtil.setIfAbsent(redisKey, 1, 10);
|
|
|
|
|
if (!result) {
|
|
|
|
|
String errorMsg = String.format("syncIdcSps----process------------同步回滚[%s]重复进入", entry.getKey().getRemark());
|
|
|
|
|
logger.error(errorMsg);
|
|
|
|
|
}
|
|
|
|
|
if ((boolean) entry.getValue().get("isNew")) {
|
|
|
|
|
basicExportTimeService.deleteById(entry.getValue().get("id").toString());
|
|
|
|
|
} else {
|
|
|
|
|
basicExportTimeService.update(Wrappers.lambdaUpdate(BasicExportStatusTimeEntity.class)
|
|
|
|
|
.set(BasicExportStatusTimeEntity::getLastUpdateTime, entry.getValue().get("oldDate"))
|
|
|
|
|
.eq(BasicExportStatusTimeEntity::getKey, entry.getKey().getKey())
|
|
|
|
|
.eq(BasicExportStatusTimeEntity::getId, entry.getValue().get("id"))
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (StrUtil.isNotBlank(delFilePath)) {
|
|
|
|
|
try {
|
|
|
|
|
File file = new File(delFilePath);
|
|
|
|
|
file.deleteOnExit();
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
String errorMsg = String.format("syncIdcSps----process------------同步回滚[%s]删除文件异常", exportType.getRemark());
|
|
|
|
|
logger.error(errorMsg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String writeFile(String filePath, String fileDesc, String content) throws IOException {
|
|
|
|
|
filePath = String.format("%s/%s", filePath, DateUtil.getDate());
|
|
|
|
|
String fileFullPath = String.format("%s/%s-%s.udi", filePath, fileDesc, IdUtil.fastSimpleUUID());
|
|
|
|
|
File file = new File(filePath);
|
|
|
|
|
if (!file.exists()) {
|
|
|
|
|
file.mkdirs();
|
|
|
|
|
}
|
|
|
|
|
file = new File(fileFullPath);
|
|
|
|
|
while (!file.createNewFile()) {
|
|
|
|
|
fileFullPath = String.format("%s/%s/%s-%s.udi", filePath, DateUtil.getDate(), fileDesc, IdUtil.fastSimpleUUID());
|
|
|
|
|
file = new File(fileFullPath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FileWriter fileWriter = new FileWriter(file);
|
|
|
|
|
fileWriter.write(content);
|
|
|
|
|
fileWriter.flush();
|
|
|
|
|
fileWriter.close();
|
|
|
|
|
return fileFullPath;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//获取需要同步信息
|
|
|
|
|
public BaseResponse findOrder(SpsSyncDataRequest spsSyncDataRequest) {
|
|
|
|
|
SpsSyncOrderResponse syncOrderResponse = new SpsSyncOrderResponse();
|
|
|
|
|
|
|
|
|
|
//查询数据同步设置
|
|
|
|
|
List<IoOrderEntity> orderEntities = new ArrayList<>();
|
|
|
|
|
if (StrUtil.isEmpty(spsSyncDataRequest.getBillNo())) {
|
|
|
|
|
SyncDataSetResponse syncDataSetEntity = syncDataSetService.selectSet();
|
|
|
|
|
FilterOrderRequest orderFilterRequest = new FilterOrderRequest();
|
|
|
|
|
BeanUtils.copyProperties(spsSyncDataRequest, orderFilterRequest);
|
|
|
|
|
if (CollUtil.isNotEmpty(syncDataSetEntity.getBusTypes())) {
|
|
|
|
|
for (SyncDataBustypeEntity syncDataBustypeEntity : syncDataSetEntity.getBusTypes()) {
|
|
|
|
|
List<IoOrderEntity> temps = orderService.findByStatus(syncDataBustypeEntity.getAction(), syncDataBustypeEntity.getOrderStatus(), DateUtil.parseDate(spsSyncDataRequest.getLastUpdateTime()));
|
|
|
|
|
if (CollUtil.isNotEmpty(temps)) {
|
|
|
|
|
orderEntities.addAll(temps);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
IoOrderEntity orderEntity = orderService.findByBillNo(spsSyncDataRequest.getBillNo());
|
|
|
|
|
orderEntities.add(orderEntity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
syncOrderResponse.setOrderEntities(orderEntities);
|
|
|
|
|
List<IoCodeEntity> codeEntities = new ArrayList<>();
|
|
|
|
|
List<IoOrderDetailBizEntity> orderDetailBizEntities = new ArrayList<>();
|
|
|
|
|
List<IoOrderDetailCodeEntity> orderDetailCodeEntities = new ArrayList<>();
|
|
|
|
|
List<IoOrderDetailResultEntity> orderDetailResultEntities = new ArrayList<>();
|
|
|
|
|
List<IoOrderInvoiceEntity> orderInvoiceEntities = new ArrayList<>();
|
|
|
|
|
List<String> syncFiles = new ArrayList<>();
|
|
|
|
|
if (CollUtil.isNotEmpty(orderEntities)) {
|
|
|
|
|
for (IoOrderEntity orderEntity : orderEntities) {
|
|
|
|
|
|
|
|
|
|
List<IoCodeEntity> codes = codesService.findByOrderId(orderEntity.getBillNo());
|
|
|
|
|
if (CollUtil.isNotEmpty(codes)) {
|
|
|
|
|
codeEntities.addAll(codes);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<IoOrderDetailBizEntity> bizEntities = orderDetailBizService.findByOrderId(orderEntity.getBillNo());
|
|
|
|
|
if (CollUtil.isNotEmpty(bizEntities)) {
|
|
|
|
|
orderDetailBizEntities.addAll(bizEntities);
|
|
|
|
|
for (IoOrderDetailBizEntity bizEntity : bizEntities) {
|
|
|
|
|
if (StrUtil.isNotEmpty(bizEntity.getCheckFileName())) {
|
|
|
|
|
syncFiles.add(bizEntity.getCheckFileName());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<IoOrderDetailCodeEntity> detailCodeEntities = orderDetailCodeService.findByOrderId(orderEntity.getBillNo());
|
|
|
|
|
if (CollUtil.isNotEmpty(detailCodeEntities)) {
|
|
|
|
|
orderDetailCodeEntities.addAll(detailCodeEntities);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<IoOrderDetailResultEntity> detailResultEntities = orderDetailResultService.findByOrderId(orderEntity.getBillNo());
|
|
|
|
|
if (CollUtil.isNotEmpty(detailResultEntities)) {
|
|
|
|
|
orderDetailResultEntities.addAll(detailResultEntities);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<IoOrderInvoiceEntity> invoiceEntities = orderInvoiceService.findByBillNo(orderEntity.getBillNo());
|
|
|
|
|
if (CollUtil.isNotEmpty(invoiceEntities)) {
|
|
|
|
|
|
|
|
|
|
for (IoOrderInvoiceEntity orderInvoiceEntity : invoiceEntities) {
|
|
|
|
|
if (StrUtil.isNotEmpty(orderInvoiceEntity.getLicenseUrl())) {
|
|
|
|
|
syncFiles.add(orderInvoiceEntity.getLicenseUrl());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
orderInvoiceEntities.addAll(invoiceEntities);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
syncOrderResponse.setFiles(syncFiles);
|
|
|
|
|
syncOrderResponse.setCodeEntities(codeEntities);
|
|
|
|
|
syncOrderResponse.setOrderDetailBizEntities(orderDetailBizEntities);
|
|
|
|
|
syncOrderResponse.setOrderDetailCodeEntities(orderDetailCodeEntities);
|
|
|
|
|
syncOrderResponse.setOrderDetailResultEntities(orderDetailResultEntities);
|
|
|
|
|
syncOrderResponse.setOrderInvoiceEntities(orderInvoiceEntities);
|
|
|
|
|
return ResultVOUtils.success(syncOrderResponse);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取需要同步国家库数据
|
|
|
|
|
@Resource
|
|
|
|
|
ProductInfoService productInfoService;
|
|
|
|
|
@Resource
|
|
|
|
|
UdiCompanyService udiCompanyService;
|
|
|
|
|
|
|
|
|
|
//udi同步数据
|
|
|
|
|
public BaseResponse syncUdi(SpsSyncDataRequest spsSyncDataRequest) {
|
|
|
|
|
SpSyncUdiResponse spSyncUdiResponse = new SpSyncUdiResponse();
|
|
|
|
|
SyncDataSetResponse syncDataSetEntity = syncDataSetService.selectSet();
|
|
|
|
|
if (syncDataSetEntity.getDbDiProducts() == 2) {
|
|
|
|
|
ProductInfoFilterRequest productInfoFilterRequest = new ProductInfoFilterRequest();
|
|
|
|
|
BeanUtils.copyProperties(spsSyncDataRequest, productInfoFilterRequest);
|
|
|
|
|
productInfoFilterRequest.setUpdateTime(spsSyncDataRequest.getLastUpdateTime());
|
|
|
|
|
List<ProductInfoEntity> productInfoEntityList = productInfoService.syncDlUdi(productInfoFilterRequest);
|
|
|
|
|
spSyncUdiResponse.setProductInfoEntityList(productInfoEntityList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (syncDataSetEntity.getDbDiCompany() == 2) {
|
|
|
|
|
UdiCompanyRequest udiCompanyRequest = new UdiCompanyRequest();
|
|
|
|
|
BeanUtils.copyProperties(spsSyncDataRequest, udiCompanyRequest);
|
|
|
|
|
udiCompanyRequest.setUpdateTime(spsSyncDataRequest.getLastUpdateTime());
|
|
|
|
|
List<UdiCompanyEntity> udiCompanyEntities = udiCompanyService.syncDlCompany(udiCompanyRequest);
|
|
|
|
|
spSyncUdiResponse.setUdiCompanyEntities(udiCompanyEntities);
|
|
|
|
|
}
|
|
|
|
|
return ResultVOUtils.success(spSyncUdiResponse);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public SpsSyncDataRequest getRequest(String type) {
|
|
|
|
|
SpsSyncDataRequest spsSyncDataRequest = new SpsSyncDataRequest();
|
|
|
|
|
spsSyncDataRequest.setPage(1);
|
|
|
|
|
spsSyncDataRequest.setLimit(1);
|
|
|
|
|
BasicExportStatusTimeEntity basicExportStatusTimeEntity = basicExportTimeService.findByType(type);
|
|
|
|
|
spsSyncDataRequest.setLastUpdateTime(basicExportStatusTimeEntity.getLastUpdateTime());
|
|
|
|
|
return spsSyncDataRequest;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|