数据同步问题相关修改

dev
anthonywj 2 years ago
parent f31a16bccf
commit ade2dd215d

@ -49,7 +49,7 @@ public class HdSchemaExecutor implements ApplicationRunner {
String sql = IoUtil.readUtf8(inputStream); String sql = IoUtil.readUtf8(inputStream);
try { try {
//判断版本表是否存在 //判断版本表是否存在
int count = hdCommonDao.selectTableExist("hd_version"); int count = hdCommonDao.selectTableExist("sys_db_version");
if (count == 0) { if (count == 0) {
hdCommonDao.updateSql(sql); hdCommonDao.updateSql(sql);
} }

@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.glxp.api.common.res.BaseResponse; import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils; import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.constant.*; import com.glxp.api.constant.*;
import com.glxp.api.constant.Constant;
import com.glxp.api.dao.basic.BasicProductsDao; import com.glxp.api.dao.basic.BasicProductsDao;
import com.glxp.api.entity.basic.*; import com.glxp.api.entity.basic.*;
import com.glxp.api.entity.inout.*; import com.glxp.api.entity.inout.*;
@ -29,12 +30,10 @@ import com.glxp.api.service.inout.*;
import com.glxp.api.service.inout.impl.IoOrderInvoiceService; import com.glxp.api.service.inout.impl.IoOrderInvoiceService;
import com.glxp.api.service.purchase.*; import com.glxp.api.service.purchase.*;
import com.glxp.api.service.thrsys.IThrBusTypeOriginService; import com.glxp.api.service.thrsys.IThrBusTypeOriginService;
import com.glxp.api.util.CustomUtil; import com.glxp.api.util.*;
import com.glxp.api.util.DateUtil;
import com.glxp.api.util.JsonUtils;
import com.glxp.api.util.RedisUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
@ -93,22 +92,25 @@ public class SpsSyncDownloadService {
log.info("创建单据同步任务"); log.info("创建单据同步任务");
//自动创建要求被下载已完成单据任务. //自动创建要求被下载已完成单据任务.
// 1.判断是否同步任务已存在 // 1.判断是否同步任务已存在
Date curTime = new Date();
BasicExportStatusEntity basicExportStatusEntity1 = basicExportService.getOne(Wrappers.lambdaQuery(BasicExportStatusEntity.class) BasicExportStatusEntity basicExportStatusEntity1 = basicExportService.getOne(Wrappers.lambdaQuery(BasicExportStatusEntity.class)
.eq(BasicExportStatusEntity::getType, NEW_ALL_ORDER) .eq(BasicExportStatusEntity::getType, NEW_ALL_ORDER)
.orderByDesc(BasicExportStatusEntity::getStartTime) .orderByDesc(BasicExportStatusEntity::getStartTime)
.last("limit 1") .last("limit 1")
); );
log.info("no1:" + basicExportStatusEntity1.getStatus() + "---" + BasicExportStatusEnum.COMPLETED.getCode());
//首次任务or上次任务结束 //首次任务or上次任务结束
if (basicExportStatusEntity1 == null || BasicExportStatusEnum.COMPLETED.getCode().equals(basicExportStatusEntity1.getStatus())) { if (basicExportStatusEntity1 == null || IntUtil.value(BasicExportStatusEnum.COMPLETED.getCode()) == IntUtil.value(basicExportStatusEntity1.getStatus())) {
log.info("no2:" + basicExportStatusEntity1.getStatus() + "---" + BasicExportStatusEnum.COMPLETED.getCode());
SpsSyncDataRequest spsSyncDataRequest = getRequest(ConstantStatus.SYNC_DOWNLOAD_SCAN_ORDER); SpsSyncDataRequest spsSyncDataRequest = getRequest(ConstantStatus.SYNC_DOWNLOAD_SCAN_ORDER);
if (lastUpdateTime != null) if (lastUpdateTime != null)
spsSyncDataRequest.setLastUpdateTime(DateUtil.formatDateTime(lastUpdateTime)); spsSyncDataRequest.setLastUpdateTime(DateUtil.formatDateTime(lastUpdateTime));
BaseResponse<SpsSyncOrderResponse> baseResponse = findOrder(spsSyncDataRequest); BaseResponse<SpsSyncOrderResponse> baseResponse = findOrder(spsSyncDataRequest);
SpsSyncOrderResponse syncOrderResponse = baseResponse.getData(); SpsSyncOrderResponse syncOrderResponse = baseResponse.getData();
log.info("no4:" + syncOrderResponse);
// 2.查看是否有需要更新的数据 // 2.查看是否有需要更新的数据
if (CollUtil.isNotEmpty(syncOrderResponse.getOrderEntities())) { if (CollUtil.isNotEmpty(syncOrderResponse.getOrderEntities())) {
log.info("no5:" + syncOrderResponse.getOrderEntities().size());
// 3.插入到任务表,等待获取 // 3.插入到任务表,等待获取
BasicExportStatusEntity orderStatusEntity = new BasicExportStatusEntity(); BasicExportStatusEntity orderStatusEntity = new BasicExportStatusEntity();
orderStatusEntity.setId(CustomUtil.getId()); orderStatusEntity.setId(CustomUtil.getId());
@ -116,7 +118,7 @@ public class SpsSyncDownloadService {
orderStatusEntity.setType(NEW_ALL_ORDER); orderStatusEntity.setType(NEW_ALL_ORDER);
orderStatusEntity.setUpdateTime(new Date()); orderStatusEntity.setUpdateTime(new Date());
orderStatusEntity.setStatus(BasicExportStatusEnum.WAIT_SYNC.getCode()); orderStatusEntity.setStatus(BasicExportStatusEnum.WAIT_SYNC.getCode());
orderStatusEntity.setStartTime(new Date()); orderStatusEntity.setStartTime(curTime);
orderStatusEntity.setScheduleType(BasicProcessStatus.SCHEDULE_NORMAL); orderStatusEntity.setScheduleType(BasicProcessStatus.SCHEDULE_NORMAL);
if (lastUpdateTime != null) { if (lastUpdateTime != null) {
@ -127,6 +129,7 @@ public class SpsSyncDownloadService {
orderStatusEntity.setRemark(baseResponse.getData().getSyncRemark()); orderStatusEntity.setRemark(baseResponse.getData().getSyncRemark());
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
log.error("no6:" + ExceptionUtils.getStackTrace(e));
} }
} }
basicExportService.insertExportStatus(orderStatusEntity); basicExportService.insertExportStatus(orderStatusEntity);
@ -931,6 +934,7 @@ public class SpsSyncDownloadService {
syncOrderResponse.setOrderDetailCodeEntities(orderDetailCodeEntities); syncOrderResponse.setOrderDetailCodeEntities(orderDetailCodeEntities);
syncOrderResponse.setOrderDetailResultEntities(orderDetailResultEntities); syncOrderResponse.setOrderDetailResultEntities(orderDetailResultEntities);
syncOrderResponse.setOrderInvoiceEntities(orderInvoiceEntities); syncOrderResponse.setOrderInvoiceEntities(orderInvoiceEntities);
log.info("no3:" + logs);
return ResultVOUtils.success(syncOrderResponse); return ResultVOUtils.success(syncOrderResponse);
} }

@ -16,7 +16,7 @@ import java.util.List;
@Service @Service
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public class BasicExportServiceImpl extends ServiceImpl<BasicExportDao,BasicExportStatusEntity> implements BasicExportService { public class BasicExportServiceImpl extends ServiceImpl<BasicExportDao, BasicExportStatusEntity> implements BasicExportService {
@Resource @Resource
BasicExportDao basicExportDao; BasicExportDao basicExportDao;
@ -67,6 +67,6 @@ public class BasicExportServiceImpl extends ServiceImpl<BasicExportDao,BasicExpo
@Override @Override
public BasicExportStatusEntity findLast(String idDatas) { public BasicExportStatusEntity findLast(String idDatas) {
return null; return basicExportDao.findLast(idDatas);
} }
} }

Loading…
Cancel
Save