|
|
|
@ -3,10 +3,13 @@ package com.glxp.api.admin.thread;
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
|
import com.glxp.api.admin.constant.BasicProcessStatus;
|
|
|
|
|
import com.glxp.api.admin.constant.ThirdSysConstant;
|
|
|
|
|
import com.glxp.api.admin.dao.basic.BasicThirdSysDao;
|
|
|
|
|
import com.glxp.api.admin.dao.basic.BasicThirdSysDetailDao;
|
|
|
|
|
import com.glxp.api.admin.dao.schedule.ScheduledDao;
|
|
|
|
|
import com.glxp.api.admin.dao.schedule.SystemParamConfigDao;
|
|
|
|
|
import com.glxp.api.admin.entity.basic.BasicThirdSysBusApiEntity;
|
|
|
|
|
import com.glxp.api.admin.entity.basic.BasicThirdSysDetailEntity;
|
|
|
|
|
import com.glxp.api.admin.entity.basic.BussinessOriginTypeEntity;
|
|
|
|
|
import com.glxp.api.admin.entity.info.ScheduledEntity;
|
|
|
|
|
import com.glxp.api.admin.entity.info.SystemParamConfigEntity;
|
|
|
|
@ -62,6 +65,8 @@ public class DownloadThirdSysDataTask implements SchedulingConfigurer {
|
|
|
|
|
private ErpBasicClient erpBasicClient;
|
|
|
|
|
@Resource
|
|
|
|
|
private BussinessOriginTypeService bussinessOriginTypeService;
|
|
|
|
|
@Resource
|
|
|
|
|
private BasicThirdSysDetailDao basicThirdSysDetailDao;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
|
|
|
|
@ -90,82 +95,95 @@ public class DownloadThirdSysDataTask implements SchedulingConfigurer {
|
|
|
|
|
List<String> thirdIds = basicThirdSysDao.selectEnabledThirdId();
|
|
|
|
|
if (CollUtil.isNotEmpty(thirdIds)) {
|
|
|
|
|
for (String thirdId : thirdIds) {
|
|
|
|
|
|
|
|
|
|
log.info("自动下载第三方系统为:{} 的基础数据", thirdId);
|
|
|
|
|
log.info("开始下载第三方系统的仓库数据");
|
|
|
|
|
BaseResponse baseResponse = thrInvWarehouseService.downloadThirdWarehouse(thirdId);
|
|
|
|
|
if (baseResponse.getCode() == 20000) {
|
|
|
|
|
log.info("第三方系统标识为:{} 的仓库数据下载完成", thirdId);
|
|
|
|
|
} else {
|
|
|
|
|
log.info(thirdId + " 仓库数据下载失败");
|
|
|
|
|
log.error(JSONUtil.toJsonStr(baseResponse));
|
|
|
|
|
//查询此系统的仓库仓位码配置详情
|
|
|
|
|
BasicThirdSysDetailEntity warehouseConfig = basicThirdSysDetailDao.selectByKey(ThirdSysConstant.WAREHOUSE_QUERY_URL, thirdId);
|
|
|
|
|
if (null != warehouseConfig && warehouseConfig.getFromType().equals(3) && warehouseConfig.getEnabled()) {
|
|
|
|
|
log.info("自动下载第三方系统为:{} 的基础数据", thirdId);
|
|
|
|
|
log.info("开始下载第三方系统的仓库数据");
|
|
|
|
|
BaseResponse baseResponse = thrInvWarehouseService.downloadThirdWarehouse(thirdId);
|
|
|
|
|
if (baseResponse.getCode() == 20000) {
|
|
|
|
|
log.info("第三方系统标识为:{} 的仓库数据下载完成", thirdId);
|
|
|
|
|
} else {
|
|
|
|
|
log.info(thirdId + " 仓库数据下载失败");
|
|
|
|
|
log.error(JSONUtil.toJsonStr(baseResponse));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
log.info("开始下载第三方系统的往来单位数据");
|
|
|
|
|
ThrCorpImportLogEntity thrCorpImportLogEntity = new ThrCorpImportLogEntity();
|
|
|
|
|
String genKey = CustomUtil.getId();
|
|
|
|
|
thrCorpImportLogEntity.setGenKey(genKey);
|
|
|
|
|
thrCorpImportLogEntity.setFromType("第三方系统获取");
|
|
|
|
|
thrCorpImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_PROCESS);
|
|
|
|
|
thrCorpImportLogEntity.setUpdateTime(new Date());
|
|
|
|
|
thrCorpImportLogEntity.setThirdSysFk(thirdId);
|
|
|
|
|
thrCorpImportLogService.insertImportLog(thrCorpImportLogEntity);
|
|
|
|
|
thrCorpsDlService.importCorps(genKey, null, thirdId);
|
|
|
|
|
log.info("第三方系统往来单位数据下载完成");
|
|
|
|
|
BasicThirdSysDetailEntity corpConfig = basicThirdSysDetailDao.selectByKey(ThirdSysConstant.CORP_URL, thirdId);
|
|
|
|
|
if (null != corpConfig && corpConfig.getFromType().equals(3) && corpConfig.getEnabled()) {
|
|
|
|
|
log.info("开始下载第三方系统的往来单位数据");
|
|
|
|
|
ThrCorpImportLogEntity thrCorpImportLogEntity = new ThrCorpImportLogEntity();
|
|
|
|
|
String genKey = CustomUtil.getId();
|
|
|
|
|
thrCorpImportLogEntity.setGenKey(genKey);
|
|
|
|
|
thrCorpImportLogEntity.setFromType("第三方系统获取");
|
|
|
|
|
thrCorpImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_PROCESS);
|
|
|
|
|
thrCorpImportLogEntity.setUpdateTime(new Date());
|
|
|
|
|
thrCorpImportLogEntity.setThirdSysFk(thirdId);
|
|
|
|
|
thrCorpImportLogService.insertImportLog(thrCorpImportLogEntity);
|
|
|
|
|
thrCorpsDlService.importCorps(genKey, null, thirdId);
|
|
|
|
|
log.info("第三方系统往来单位数据下载完成");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
log.info("开始下载第三方系统的产品信息数据");
|
|
|
|
|
ThrProductsImportLogEntity thrProductsImportLogEntity = new ThrProductsImportLogEntity();
|
|
|
|
|
String genKey1 = CustomUtil.getId();
|
|
|
|
|
thrProductsImportLogEntity.setGenKey(genKey1);
|
|
|
|
|
thrProductsImportLogEntity.setFromType("第三方系统下载");
|
|
|
|
|
thrProductsImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_PROCESS);
|
|
|
|
|
thrProductsImportLogEntity.setUpdateTime(new Date());
|
|
|
|
|
thrProductsImportLogEntity.setThirdSysFk(thirdId);
|
|
|
|
|
thrProductsImportLogService.insertImportLog(thrProductsImportLogEntity);
|
|
|
|
|
FilterThrProductsRequest filterThrProductsRequest = new FilterThrProductsRequest();
|
|
|
|
|
filterThrProductsRequest.setThirdSysFk(thirdId);
|
|
|
|
|
filterThrProductsRequest.setThirdSys(thirdId);
|
|
|
|
|
filterThrProductsRequest.setPage(1);
|
|
|
|
|
filterThrProductsRequest.setLimit(100);
|
|
|
|
|
thrProductsDlService.importProducrs(genKey1, filterThrProductsRequest);
|
|
|
|
|
log.info("第三方系统往来产品信息数据下载完成");
|
|
|
|
|
BasicThirdSysDetailEntity productConfig = basicThirdSysDetailDao.selectByKey(ThirdSysConstant.PI_QUERY_URL, thirdId);
|
|
|
|
|
if (null != productConfig && productConfig.getFromType().equals(3) && productConfig.getEnabled()) {
|
|
|
|
|
log.info("开始下载第三方系统的产品信息数据");
|
|
|
|
|
ThrProductsImportLogEntity thrProductsImportLogEntity = new ThrProductsImportLogEntity();
|
|
|
|
|
String genKey1 = CustomUtil.getId();
|
|
|
|
|
thrProductsImportLogEntity.setGenKey(genKey1);
|
|
|
|
|
thrProductsImportLogEntity.setFromType("第三方系统下载");
|
|
|
|
|
thrProductsImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_PROCESS);
|
|
|
|
|
thrProductsImportLogEntity.setUpdateTime(new Date());
|
|
|
|
|
thrProductsImportLogEntity.setThirdSysFk(thirdId);
|
|
|
|
|
thrProductsImportLogService.insertImportLog(thrProductsImportLogEntity);
|
|
|
|
|
FilterThrProductsRequest filterThrProductsRequest = new FilterThrProductsRequest();
|
|
|
|
|
filterThrProductsRequest.setThirdSysFk(thirdId);
|
|
|
|
|
filterThrProductsRequest.setThirdSys(thirdId);
|
|
|
|
|
filterThrProductsRequest.setPage(1);
|
|
|
|
|
filterThrProductsRequest.setLimit(100);
|
|
|
|
|
thrProductsDlService.importProducrs(genKey1, filterThrProductsRequest);
|
|
|
|
|
log.info("第三方系统往来产品信息数据下载完成");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
log.info("开始下载第三方系统单据类型");
|
|
|
|
|
FilterBasicThirdSysDetailRequest filterBasicThirdSysDetailRequest = new FilterBasicThirdSysDetailRequest();
|
|
|
|
|
filterBasicThirdSysDetailRequest.setThirdSysFk(thirdId);
|
|
|
|
|
int page = 1;
|
|
|
|
|
int limit = 100;
|
|
|
|
|
while (true) {
|
|
|
|
|
filterBasicThirdSysDetailRequest.setPage(page);
|
|
|
|
|
filterBasicThirdSysDetailRequest.setLimit(limit);
|
|
|
|
|
BaseResponse<PageSimpleResponse<BasicThirdSysBusApiEntity>> busResponse = erpBasicClient.getBusTypes(filterBasicThirdSysDetailRequest);
|
|
|
|
|
if (busResponse != null && busResponse.getCode() == 20000) {
|
|
|
|
|
List<BasicThirdSysBusApiEntity> basicThirdSysBusApiEntities = busResponse.getData().getList();
|
|
|
|
|
if (CollUtil.isNotEmpty(basicThirdSysBusApiEntities)) {
|
|
|
|
|
for (BasicThirdSysBusApiEntity basicThirdSysBusApiEntity : basicThirdSysBusApiEntities) {
|
|
|
|
|
BussinessOriginTypeEntity bussinessOriginTypeEntity = new BussinessOriginTypeEntity();
|
|
|
|
|
bussinessOriginTypeEntity.setName(basicThirdSysBusApiEntity.getName());
|
|
|
|
|
bussinessOriginTypeEntity.setAction(basicThirdSysBusApiEntity.getCode());
|
|
|
|
|
bussinessOriginTypeEntity.setThirdSys(thirdId);
|
|
|
|
|
bussinessOriginTypeEntity.setInoutType(basicThirdSysBusApiEntity.getInoutType());
|
|
|
|
|
bussinessOriginTypeEntity.setRemark(basicThirdSysBusApiEntity.getRemark());
|
|
|
|
|
bussinessOriginTypeEntity.setEnable(true);
|
|
|
|
|
bussinessOriginTypeEntity.setUpdateTime(new Date());
|
|
|
|
|
bussinessOriginTypeService.insertBusOriginType(bussinessOriginTypeEntity);
|
|
|
|
|
}
|
|
|
|
|
if (basicThirdSysBusApiEntities.size() >= 100) {
|
|
|
|
|
page++;
|
|
|
|
|
} else
|
|
|
|
|
BasicThirdSysDetailEntity busConfig = basicThirdSysDetailDao.selectByKey(ThirdSysConstant.BUS_TYPE_QUERY_URL, thirdId);
|
|
|
|
|
if (null != busConfig && busConfig.getFromType().equals(3) && busConfig.getEnabled()) {
|
|
|
|
|
log.info("开始下载第三方系统单据类型");
|
|
|
|
|
FilterBasicThirdSysDetailRequest filterBasicThirdSysDetailRequest = new FilterBasicThirdSysDetailRequest();
|
|
|
|
|
filterBasicThirdSysDetailRequest.setThirdSysFk(thirdId);
|
|
|
|
|
int page = 1;
|
|
|
|
|
int limit = 100;
|
|
|
|
|
while (true) {
|
|
|
|
|
filterBasicThirdSysDetailRequest.setPage(page);
|
|
|
|
|
filterBasicThirdSysDetailRequest.setLimit(limit);
|
|
|
|
|
BaseResponse<PageSimpleResponse<BasicThirdSysBusApiEntity>> busResponse = erpBasicClient.getBusTypes(filterBasicThirdSysDetailRequest);
|
|
|
|
|
if (busResponse != null && busResponse.getCode() == 20000) {
|
|
|
|
|
List<BasicThirdSysBusApiEntity> basicThirdSysBusApiEntities = busResponse.getData().getList();
|
|
|
|
|
if (CollUtil.isNotEmpty(basicThirdSysBusApiEntities)) {
|
|
|
|
|
for (BasicThirdSysBusApiEntity basicThirdSysBusApiEntity : basicThirdSysBusApiEntities) {
|
|
|
|
|
BussinessOriginTypeEntity bussinessOriginTypeEntity = new BussinessOriginTypeEntity();
|
|
|
|
|
bussinessOriginTypeEntity.setName(basicThirdSysBusApiEntity.getName());
|
|
|
|
|
bussinessOriginTypeEntity.setAction(basicThirdSysBusApiEntity.getCode());
|
|
|
|
|
bussinessOriginTypeEntity.setThirdSys(thirdId);
|
|
|
|
|
bussinessOriginTypeEntity.setInoutType(basicThirdSysBusApiEntity.getInoutType());
|
|
|
|
|
bussinessOriginTypeEntity.setRemark(basicThirdSysBusApiEntity.getRemark());
|
|
|
|
|
bussinessOriginTypeEntity.setEnable(true);
|
|
|
|
|
bussinessOriginTypeEntity.setUpdateTime(new Date());
|
|
|
|
|
bussinessOriginTypeService.insertBusOriginType(bussinessOriginTypeEntity);
|
|
|
|
|
}
|
|
|
|
|
if (basicThirdSysBusApiEntities.size() >= 100) {
|
|
|
|
|
page++;
|
|
|
|
|
} else
|
|
|
|
|
break;
|
|
|
|
|
} else {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
log.error("第三方系统单据类型数据下载失败");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
log.error("第三方系统单据类型数据下载失败");
|
|
|
|
|
break;
|
|
|
|
|
log.info("第三方系统往来产品信息数据下载完成");
|
|
|
|
|
}
|
|
|
|
|
log.info("第三方系统往来产品信息数据下载完成");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|