|
|
|
@ -1,10 +1,22 @@
|
|
|
|
|
package com.glxp.api.service.thrsys;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
|
|
import com.glxp.api.common.res.BaseResponse;
|
|
|
|
|
import com.glxp.api.common.util.ResultVOUtils;
|
|
|
|
|
import com.glxp.api.dao.dev.DeviceBusinessProjectDeviceMapper;
|
|
|
|
|
import com.glxp.api.entity.basic.BasicSkProjectEntity;
|
|
|
|
|
import com.glxp.api.entity.dev.DeviceBusinessProjectDevice;
|
|
|
|
|
import com.glxp.api.exception.JsonException;
|
|
|
|
|
import com.glxp.api.http.ErpBasicClient;
|
|
|
|
|
import com.glxp.api.req.dev.DeviceBusinessProjectRequest;
|
|
|
|
|
import com.glxp.api.res.PageSimpleResponse;
|
|
|
|
|
import com.glxp.api.res.basic.BasicSkProjectResponse;
|
|
|
|
|
import com.glxp.api.res.dev.DeviceBusinessProjectVo;
|
|
|
|
|
import com.glxp.api.vo.dev.DeviceCheckVo;
|
|
|
|
|
import com.glxp.api.vo.dev.DeviceInfoVo;
|
|
|
|
@ -13,10 +25,14 @@ import javax.annotation.Resource;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.math.MathContext;
|
|
|
|
|
import java.math.RoundingMode;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
import com.glxp.api.dao.dev.DeviceBusinessProjectMapper;
|
|
|
|
|
import com.glxp.api.entity.dev.DeviceBusinessProject;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
public class DeviceBusinessProjectService extends ServiceImpl<DeviceBusinessProjectMapper, DeviceBusinessProject> {
|
|
|
|
|
|
|
|
|
@ -83,4 +99,57 @@ public class DeviceBusinessProjectService extends ServiceImpl<DeviceBusinessProj
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
ErpBasicClient erpBasicClient;
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public void downloadDeviceBusinessProject(DeviceBusinessProjectRequest query) {
|
|
|
|
|
|
|
|
|
|
//删除原本的日期区间的内容 更新下载
|
|
|
|
|
this.remove(new LambdaQueryWrapper<DeviceBusinessProject>()
|
|
|
|
|
.ge(StrUtil.isNotEmpty(query.getStartChargTime()),DeviceBusinessProject::getChargTime,query.getStartChargTime())
|
|
|
|
|
.le(StrUtil.isNotEmpty(query.getEndChargTime()),DeviceBusinessProject::getChargTime,query.getEndChargTime())
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
int page = 1;
|
|
|
|
|
int limit = 500;
|
|
|
|
|
query.setThirdSys("thirdId");
|
|
|
|
|
query.setLimit(limit);
|
|
|
|
|
List<DeviceBusinessProject> addList = new ArrayList<>();
|
|
|
|
|
while (true) {
|
|
|
|
|
query.setPage(page);
|
|
|
|
|
BaseResponse<PageSimpleResponse<DeviceBusinessProject>> baseResponse = erpBasicClient.getDeviceBusinessProject(query);
|
|
|
|
|
if (baseResponse.getCode() == 20000) {
|
|
|
|
|
List<DeviceBusinessProject> list = baseResponse.getData().getList();
|
|
|
|
|
if (CollUtil.isNotEmpty(list)) {
|
|
|
|
|
list.forEach(item -> {
|
|
|
|
|
item.setId(null);
|
|
|
|
|
item.setCreateTime(new Date());
|
|
|
|
|
item.setUpdateTime(new Date());
|
|
|
|
|
// TODO: 2024/12/6 物资系统的部门编码转化 自身系统的编码和名称
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
addList.add(item);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (list.size() >= limit && !baseResponse.getData().getTotal().equals(-666)) {
|
|
|
|
|
page++;
|
|
|
|
|
} else {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
throw new JsonException("下载异常中断");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (addList.size() >= 500){
|
|
|
|
|
this.saveBatch(addList);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(addList)){
|
|
|
|
|
this.saveBatch(addList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|