|
|
|
@ -1,7 +1,11 @@
|
|
|
|
|
package com.glxp.api.service.thrsys.impl;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
|
|
import com.glxp.api.common.res.BaseResponse;
|
|
|
|
@ -20,10 +24,10 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
@ -126,7 +130,7 @@ public class ThrDeptServiceImpl extends ServiceImpl<ThrDeptDao, ThrDeptEntity> i
|
|
|
|
|
@Override
|
|
|
|
|
public BaseResponse downloadThirdWarehouse(String thirdSysFk) {
|
|
|
|
|
int page = 1;
|
|
|
|
|
int limit = 100;
|
|
|
|
|
int limit = 1000;
|
|
|
|
|
while (true) {
|
|
|
|
|
UdiwmsWarehouseRequest udiwmsWarehouseRequest = new UdiwmsWarehouseRequest();
|
|
|
|
|
udiwmsWarehouseRequest.setThirdSys(thirdSysFk);
|
|
|
|
@ -135,42 +139,89 @@ public class ThrDeptServiceImpl extends ServiceImpl<ThrDeptDao, ThrDeptEntity> i
|
|
|
|
|
BaseResponse<PageSimpleResponse<UdiwmsWarehouseDetail>> baseResponse = erpBasicClient.getWarehouse(udiwmsWarehouseRequest);
|
|
|
|
|
if (baseResponse.getCode() == 20000) {
|
|
|
|
|
List<UdiwmsWarehouseDetail> responseList = baseResponse.getData().getList();
|
|
|
|
|
List<ThrDeptEntity> list = new ArrayList<>();
|
|
|
|
|
List<ThrInvWarehouseEntity> warehouseList = new ArrayList<>();
|
|
|
|
|
for (UdiwmsWarehouseDetail response : responseList) {
|
|
|
|
|
ThrDeptEntity thrDeptEntity = new ThrDeptEntity();
|
|
|
|
|
thrDeptEntity.setPid(0);
|
|
|
|
|
thrDeptEntity.setName(response.getName());
|
|
|
|
|
thrDeptEntity.setCode(response.getCode());
|
|
|
|
|
if (CollUtil.isNotEmpty(responseList)) {
|
|
|
|
|
AtomicInteger count = new AtomicInteger(); // 计数器
|
|
|
|
|
responseList.forEach(item -> {
|
|
|
|
|
ThrDeptEntity thrDeptEntity = new ThrDeptEntity();
|
|
|
|
|
ThrInvWarehouseEntity thrInvWarehouseEntity = new ThrInvWarehouseEntity();
|
|
|
|
|
BeanUtil.copyProperties(item, thrDeptEntity);
|
|
|
|
|
BeanUtil.copyProperties(item, thrInvWarehouseEntity);
|
|
|
|
|
|
|
|
|
|
thrDeptEntity.setPid(0);
|
|
|
|
|
thrDeptEntity.setName(item.getName());
|
|
|
|
|
thrDeptEntity.setCode(item.getCode());
|
|
|
|
|
thrDeptEntity.setThirdSysFk(thirdSysFk);
|
|
|
|
|
thrDeptEntity.setAdvanceType(false); //默认是仓库
|
|
|
|
|
thrDeptEntity.setStatus(1);//默认启用
|
|
|
|
|
thrDeptEntity.setUpdateTime(new Date());
|
|
|
|
|
thrDeptEntity.setId(IdUtil.getSnowflake(6, 1).nextId());
|
|
|
|
|
list.add(thrDeptEntity);
|
|
|
|
|
|
|
|
|
|
ThrInvWarehouseEntity thrInvWarehouseEntity = new ThrInvWarehouseEntity();
|
|
|
|
|
thrInvWarehouseEntity.setCode(response.getCode());
|
|
|
|
|
thrInvWarehouseEntity.setName(response.getName());
|
|
|
|
|
thrInvWarehouseEntity.setRemark(response.getRemark());
|
|
|
|
|
|
|
|
|
|
thrInvWarehouseEntity.setCode(item.getCode());
|
|
|
|
|
thrInvWarehouseEntity.setName(item.getName());
|
|
|
|
|
thrInvWarehouseEntity.setRemark(item.getRemark());
|
|
|
|
|
thrInvWarehouseEntity.setThirdSysFk(thirdSysFk);
|
|
|
|
|
thrInvWarehouseEntity.setParentId(response.getCode());
|
|
|
|
|
thrInvWarehouseEntity.setParentId(item.getCode());
|
|
|
|
|
thrInvWarehouseEntity.setId(IdUtil.getSnowflake(6, 1).nextId() + "");
|
|
|
|
|
thrInvWarehouseEntity.setUpdateTime(new Date());
|
|
|
|
|
warehouseList.add(thrInvWarehouseEntity);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boolean b = thrDeptDao.exists(new LambdaQueryWrapper<ThrDeptEntity>().eq(ThrDeptEntity::getCode, thrDeptEntity.getCode()));
|
|
|
|
|
if (b) {
|
|
|
|
|
thrDeptDao.update(thrDeptEntity, new LambdaUpdateWrapper<ThrDeptEntity>().eq(ThrDeptEntity::getCode, thrDeptEntity.getCode()));
|
|
|
|
|
} else {
|
|
|
|
|
thrDeptDao.insert(thrDeptEntity);
|
|
|
|
|
}
|
|
|
|
|
boolean b1 = thrInvWarehouseDao.exists(new LambdaQueryWrapper<ThrInvWarehouseEntity>().eq(ThrInvWarehouseEntity::getCode, thrInvWarehouseEntity.getCode()));
|
|
|
|
|
if (b1) {
|
|
|
|
|
thrInvWarehouseDao.update(thrInvWarehouseEntity, new LambdaUpdateWrapper<ThrInvWarehouseEntity>().eq(ThrInvWarehouseEntity::getCode, thrInvWarehouseEntity.getCode()));
|
|
|
|
|
} else {
|
|
|
|
|
thrInvWarehouseDao.insert(thrInvWarehouseEntity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
//插入数据
|
|
|
|
|
thrDeptDao.insertThrDeptList(list);
|
|
|
|
|
thrInvWarehouseDao.insertThrInvWarehouses(warehouseList);
|
|
|
|
|
if (list.size() >= limit) {
|
|
|
|
|
if (responseList.size() >= limit) {
|
|
|
|
|
page++;
|
|
|
|
|
} else {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
// List<ThrDeptEntity> list = new ArrayList<>();
|
|
|
|
|
// List<ThrInvWarehouseEntity> warehouseList = new ArrayList<>();
|
|
|
|
|
// for (UdiwmsWarehouseDetail response : responseList) {
|
|
|
|
|
// ThrDeptEntity thrDeptEntity = new ThrDeptEntity();
|
|
|
|
|
// thrDeptEntity.setPid(0);
|
|
|
|
|
// thrDeptEntity.setName(response.getName());
|
|
|
|
|
// thrDeptEntity.setCode(response.getCode());
|
|
|
|
|
// thrDeptEntity.setThirdSysFk(thirdSysFk);
|
|
|
|
|
// thrDeptEntity.setAdvanceType(false); //默认是仓库
|
|
|
|
|
// thrDeptEntity.setStatus(1);//默认启用
|
|
|
|
|
// thrDeptEntity.setUpdateTime(new Date());
|
|
|
|
|
// thrDeptEntity.setId(IdUtil.getSnowflake(6, 1).nextId());
|
|
|
|
|
// list.add(thrDeptEntity);
|
|
|
|
|
//
|
|
|
|
|
// ThrInvWarehouseEntity thrInvWarehouseEntity = new ThrInvWarehouseEntity();
|
|
|
|
|
// thrInvWarehouseEntity.setCode(response.getCode());
|
|
|
|
|
// thrInvWarehouseEntity.setName(response.getName());
|
|
|
|
|
// thrInvWarehouseEntity.setRemark(response.getRemark());
|
|
|
|
|
// thrInvWarehouseEntity.setThirdSysFk(thirdSysFk);
|
|
|
|
|
// thrInvWarehouseEntity.setParentId(response.getCode());
|
|
|
|
|
// thrInvWarehouseEntity.setId(IdUtil.getSnowflake(6, 1).nextId() + "");
|
|
|
|
|
// thrInvWarehouseEntity.setUpdateTime(new Date());
|
|
|
|
|
// warehouseList.add(thrInvWarehouseEntity);
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
// //插入数据
|
|
|
|
|
// thrDeptDao.insertThrDeptList(list);
|
|
|
|
|
// thrInvWarehouseDao.insertThrInvWarehouses(warehouseList);
|
|
|
|
|
// if (list.size() >= limit) {
|
|
|
|
|
// page++;
|
|
|
|
|
// } else {
|
|
|
|
|
// break;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
return baseResponse;
|
|
|
|
|
return ResultVOUtils.error(500, "下载异常中断");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|