|
|
|
@ -1,33 +1,43 @@
|
|
|
|
|
package com.glxp.api.service.sync;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import com.glxp.api.dao.basic.ProductInfoDao;
|
|
|
|
|
import com.glxp.api.dao.basic.UdiCompanyDao;
|
|
|
|
|
import com.glxp.api.dao.inout.*;
|
|
|
|
|
import com.glxp.api.entity.basic.ProductInfoEntity;
|
|
|
|
|
import com.glxp.api.entity.basic.UdiCompanyEntity;
|
|
|
|
|
import com.glxp.api.entity.inout.*;
|
|
|
|
|
import com.glxp.api.res.sync.*;
|
|
|
|
|
import com.glxp.api.service.inout.*;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.ibatis.session.ExecutorType;
|
|
|
|
|
import org.apache.ibatis.session.SqlSession;
|
|
|
|
|
import org.apache.ibatis.session.SqlSessionFactory;
|
|
|
|
|
import org.apache.ibatis.session.TransactionIsolationLevel;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.alibaba.fastjson.TypeReference;
|
|
|
|
|
import com.glxp.api.common.res.BaseResponse;
|
|
|
|
|
import com.glxp.api.common.util.ResultVOUtils;
|
|
|
|
|
import com.glxp.api.constant.BasicProcessStatus;
|
|
|
|
|
import com.glxp.api.constant.ConstantStatus;
|
|
|
|
|
import com.glxp.api.entity.inout.*;
|
|
|
|
|
import com.glxp.api.entity.sync.BasicDownloadStatusEntity;
|
|
|
|
|
import com.glxp.api.entity.sync.BasicExportStatusEntity;
|
|
|
|
|
import com.glxp.api.entity.sync.BasicExportStatusTimeEntity;
|
|
|
|
|
import com.glxp.api.http.sync.SpGetHttpClient;
|
|
|
|
|
import com.glxp.api.req.sync.SpsSyncDataRequest;
|
|
|
|
|
import com.glxp.api.res.sync.*;
|
|
|
|
|
import com.glxp.api.service.inout.*;
|
|
|
|
|
import com.glxp.api.util.CustomUtil;
|
|
|
|
|
import com.glxp.api.util.DateUtil;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.ibatis.session.SqlSessionFactory;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
@Slf4j
|
|
|
|
|
@Service
|
|
|
|
|
public class HeartService {
|
|
|
|
@ -52,6 +62,17 @@ public class HeartService {
|
|
|
|
|
@Resource
|
|
|
|
|
private UpThrDataService upThrDataService;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
IoCodeTempService codeTempService;
|
|
|
|
|
@Resource
|
|
|
|
|
IoOrderDetailBizService orderDetailBizService;
|
|
|
|
|
@Resource
|
|
|
|
|
IoOrderDetailCodeService orderDetailCodeService;
|
|
|
|
|
@Resource
|
|
|
|
|
IoOrderDetailResultService orderDetailResultService;
|
|
|
|
|
@Resource
|
|
|
|
|
IoOrderInvoiceService orderInvoiceService;
|
|
|
|
|
|
|
|
|
|
//上传最近更新扫码单据
|
|
|
|
|
public BaseResponse uploadAllOrder(String syncTime) {
|
|
|
|
|
SpsSyncDataRequest spsSyncDataRequest = new SpsSyncDataRequest();
|
|
|
|
@ -326,18 +347,7 @@ public class HeartService {
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
IoCodeTempService codeTempService;
|
|
|
|
|
@Resource
|
|
|
|
|
IoOrderDetailBizService orderDetailBizService;
|
|
|
|
|
@Resource
|
|
|
|
|
IoOrderDetailCodeService orderDetailCodeService;
|
|
|
|
|
@Resource
|
|
|
|
|
IoOrderDetailResultService orderDetailResultService;
|
|
|
|
|
@Resource
|
|
|
|
|
IoOrderInvoiceService orderInvoiceService;
|
|
|
|
|
|
|
|
|
|
//下载最近更新扫码单据
|
|
|
|
|
//下载最近更新扫码单据--上级服务
|
|
|
|
|
public void dlAllOrder() {
|
|
|
|
|
BaseResponse<List<BasicExportStatusEntity>> baseResponse = spGetHttp.getBasicStatus(BasicProcessStatus.NEW_ALL_ORDER + "");
|
|
|
|
|
List<BasicExportStatusEntity> pageSimpleResponse = baseResponse != null ? baseResponse.getData() : new ArrayList<>();
|
|
|
|
@ -417,6 +427,72 @@ public class HeartService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 下载最近更新国家库数据-上级服务
|
|
|
|
|
public void dlAllDiProducts() {
|
|
|
|
|
BaseResponse<List<BasicExportStatusEntity>> baseResponse = spGetHttp.getBasicStatus(BasicProcessStatus.NEW_ALL_DI + "");
|
|
|
|
|
List<BasicExportStatusEntity> pageSimpleResponse = baseResponse.getData();
|
|
|
|
|
if (pageSimpleResponse != null) {
|
|
|
|
|
List<BasicExportStatusEntity> basicExportStatusEntities = pageSimpleResponse;
|
|
|
|
|
if (basicExportStatusEntities != null && basicExportStatusEntities.size() > 0) {
|
|
|
|
|
for (BasicExportStatusEntity basicExportStatusEntity : basicExportStatusEntities) {
|
|
|
|
|
long curTime = System.currentTimeMillis();
|
|
|
|
|
// log.info("--------等待时间------" + curTime);
|
|
|
|
|
String datas = spGetHttp.getBasicData(basicExportStatusEntity.getId(), BasicProcessStatus.NEW_ALL_DI);
|
|
|
|
|
// logger.info("--------等待时间1------" + (System.currentTimeMillis() - curTime) / 1000);
|
|
|
|
|
long curTime2 = System.currentTimeMillis();
|
|
|
|
|
BaseResponse<SpSyncUdiResponse> response = JSONObject.parseObject(datas, new TypeReference<BaseResponse<SpSyncUdiResponse>>() {
|
|
|
|
|
});
|
|
|
|
|
// logger.info("--------等待时间2------" + (System.currentTimeMillis() - curTime2) / 1000);
|
|
|
|
|
if (response.getCode() == 20000 && response.getData() != null) {
|
|
|
|
|
SpSyncUdiResponse spSyncUdiResponse = response.getData();
|
|
|
|
|
BasicDownloadStatusEntity basicDownloadStatusEntity = new BasicDownloadStatusEntity();
|
|
|
|
|
basicDownloadStatusEntity.setId(CustomUtil.getId());
|
|
|
|
|
basicDownloadStatusEntity.setTaskId(spSyncUdiResponse.getTaskId());
|
|
|
|
|
basicDownloadStatusEntity.setStartTime(new Date());
|
|
|
|
|
basicDownloadStatusEntity.setIdDatas(ConstantStatus.SYNC_DOWNLOAD_DI_PRODUCTS);
|
|
|
|
|
basicDownloadStatusEntity.setStatus(ConstantStatus.SYNC_STATUS_WAIT); //下载中
|
|
|
|
|
basicDownloadStatusEntity.setType(BasicProcessStatus.NEW_ALL_DI);
|
|
|
|
|
basicDownloadStatusEntity.setScheduleType(1);
|
|
|
|
|
|
|
|
|
|
basicDownloadService.insertDownloadStatus(basicDownloadStatusEntity);
|
|
|
|
|
StringBuffer remark = new StringBuffer();
|
|
|
|
|
|
|
|
|
|
SqlSession batchSession = sqlSessionFactory.openSession(ExecutorType.BATCH, TransactionIsolationLevel.READ_COMMITTED);
|
|
|
|
|
if (CollUtil.isNotEmpty(spSyncUdiResponse.getUdiCompanyEntities())) {
|
|
|
|
|
List<UdiCompanyEntity> udiCompanyEntities = spSyncUdiResponse.getUdiCompanyEntities();
|
|
|
|
|
UdiCompanyDao mapper = batchSession.getMapper(UdiCompanyDao.class);
|
|
|
|
|
for (UdiCompanyEntity udiCompanyEntity : udiCompanyEntities) {
|
|
|
|
|
mapper.insertUdiCompany(udiCompanyEntity);
|
|
|
|
|
}
|
|
|
|
|
batchSession.commit();
|
|
|
|
|
remark.append("公司信息:").append(spSyncUdiResponse.getUdiCompanyEntities().size()).append("条\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(spSyncUdiResponse.getProductInfoEntityList())) {
|
|
|
|
|
List<ProductInfoEntity> productInfoEntities = spSyncUdiResponse.getProductInfoEntityList();
|
|
|
|
|
ProductInfoDao mapper = batchSession.getMapper(ProductInfoDao.class);
|
|
|
|
|
for (ProductInfoEntity productInfoEntity : productInfoEntities) {
|
|
|
|
|
mapper.insertProductInfo(productInfoEntity);
|
|
|
|
|
}
|
|
|
|
|
batchSession.commit();
|
|
|
|
|
remark.append("产品信息:").append(spSyncUdiResponse.getProductInfoEntityList().size()).append("条\n");
|
|
|
|
|
}
|
|
|
|
|
batchSession.close();
|
|
|
|
|
spGetHttp.postBasicStatus(basicExportStatusEntity.getId());
|
|
|
|
|
|
|
|
|
|
basicDownloadStatusEntity.setUpdateTime(new Date());
|
|
|
|
|
basicDownloadStatusEntity.setEndTime(new Date());
|
|
|
|
|
basicDownloadStatusEntity.setRemark(remark.toString());
|
|
|
|
|
basicDownloadStatusEntity.setStatus(ConstantStatus.SYNC_STATUS_SUCCESS);
|
|
|
|
|
basicDownloadService.updateDownloadStatus(basicDownloadStatusEntity);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void insetOrderDb(SpsSyncOrderResponse syncDataResponse, IoOrderEntity orderEntity) {
|
|
|
|
|
//更新码详情
|
|
|
|
|
if (CollUtil.isNotEmpty(syncDataResponse.getOrderDetailCodeEntities())) {
|
|
|
|
|