空数据不写入问题

dev
anthonywj 8 months ago
parent 2336637294
commit 4d2ec8c834

@ -63,6 +63,11 @@ public enum BasicExportTypeEnum {
DEVICE_REPAIR_DATA("device_repair_apply", "报修管理数据"),
DEVICE_UPKEEP_DATA("device__upkeep", "设备保养数据"),
/**
*
*/
DEVICE_TASK("device_task", "设备任务"),
;
private String key;

@ -290,30 +290,43 @@ public class DlAllDataService {
idcService.batchDownloadFile(spGetHttp.getSpmsUrl(), list.toArray(new String[list.size()]));
}
if (StrUtil.isNotBlank(bean.getTaskId())) {
// 将数据写入文件
// try {
FileUtils.makeDirectory(filePath + "sync/");
String fileName = filePath + "sync/" + exportType.getRemark() + "-" + bean.getTaskId() + ".udi";
FileUtils.SaveFileAs(bean.getFileContent(), fileName);
// } catch (IOException e) {
// log.error("从UDI自助平台拉取基础数据 文件[{}]写入异常----{}",bean.getFilePath(), e.getMessage());
// throw new RuntimeException(e);
// }
BasicExportStatusEntity exportStatusEntity = BasicExportStatusEntity.builder()
.id(bean.getTaskId())
.taskId(bean.getTaskId())
.status(BasicExportStatusEnum.WAIT_SYNC.getCode())
.type(exportType.getRemark())
.transportType(1)
.scheduleType(1)
.fromType(1).remark(remark)
.startTime(DateUtil.getDateTime())
.updateTime(new Date())
.cacheFilePath(fileName)
.build();
basicExportService.insertExportStatus(exportStatusEntity);
//通知自助平台任务已完成
spGetHttp.finishTask(bean.getTaskId());
if (StrUtil.isNotBlank(bean.getFileContent()) && !bean.getFileContent().contains("系统繁忙")) {
FileUtils.makeDirectory(filePath + "sync/");
String fileName = filePath + "sync/" + exportType.getRemark() + "-" + bean.getTaskId() + ".udi";
FileUtils.SaveFileAs(bean.getFileContent(), fileName);
BasicExportStatusEntity exportStatusEntity = BasicExportStatusEntity.builder()
.id(bean.getTaskId())
.taskId(bean.getTaskId())
.status(BasicExportStatusEnum.WAIT_SYNC.getCode())
.type(exportType.getRemark())
.transportType(1)
.scheduleType(1)
.fromType(1).remark(remark)
.startTime(DateUtil.getDateTime())
.updateTime(new Date())
.cacheFilePath(fileName)
.build();
basicExportService.insertExportStatus(exportStatusEntity);
//通知自助平台任务已完成
spGetHttp.finishTask(bean.getTaskId());
} else {
BasicExportStatusEntity exportStatusEntity = BasicExportStatusEntity.builder()
.id(bean.getTaskId())
.taskId(bean.getTaskId())
.status(BasicExportStatusEnum.WAIT_SYNC.getCode())
.type(exportType.getRemark())
.transportType(1)
.scheduleType(1)
.fromType(1).remark("异常数据,空数据")
.startTime(DateUtil.getDateTime())
.updateTime(new Date())
.cacheFilePath("")
.build();
basicExportService.insertExportStatus(exportStatusEntity);
spGetHttp.finishTask(bean.getTaskId());
}
}
}
}

@ -1,24 +1,15 @@
package com.glxp.sale.admin.thread.didl;
import com.alibaba.fastjson.JSON;
import com.glxp.sale.admin.constant.FileConstant;
import com.glxp.sale.admin.entity.param.SystemParamConfigEntity;
import com.glxp.sale.admin.entity.sync.BasicExportStatusEntity;
import com.glxp.sale.admin.entity.sync.UdiCompanyEntity;
import com.glxp.sale.admin.service.param.SystemParamConfigService;
import com.glxp.sale.admin.service.sync.BasicExportService;
import com.glxp.sale.admin.util.FileUtils;
import com.glxp.sale.admin.util.RedisUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
@Service
public class AsyncCompanyDlService {
@ -41,41 +32,41 @@ public class AsyncCompanyDlService {
@Async
public void asyncDiByTime(String updateTime) {
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("sync_upstream_enable");
if (systemParamConfigEntity.getParamValue().equals("1")) {
List<UdiCompanyEntity> mUdiCompanyEntities = new ArrayList<>();
int page = 1;
int limit = 300;
while (true) {
logger.info("更新时间:" + updateTime + "----" + page + "----" + limit);
List<UdiCompanyEntity> udiCompanyEntities = asyncDiDlHelper.dlCompanyByTime(page, limit, updateTime);
if (udiCompanyEntities != null && udiCompanyEntities.size() > 0) {
mUdiCompanyEntities.addAll(udiCompanyEntities);
if (udiCompanyEntities.size() < limit) {
break;
} else {
page++;
}
} else {
break;
}
}
logger.info("更新时间:" + updateTime + "----" + "下载结束");
SystemParamConfigEntity downstream = systemParamConfigService.selectByParamKey("sync_downstream_enable");
String key = "UdiCompanys" + System.currentTimeMillis();
String datas = JSON.toJSON(mUdiCompanyEntities).toString();
if (downstream.getParamValue().equals("1")) {
redisUtil.set(key, datas);
BasicExportStatusEntity myEntity = new BasicExportStatusEntity();
myEntity.setId(key);
basicExportService.insertExportStatus(myEntity);
} else {
String path = getPath();
String fileName = path + FileConstant.upWaitCopy_products + "UdiCompanys_" + key + ".LowerIn";
FileUtils.SaveFileAs(datas, fileName);
}
}
// SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("sync_upstream_enable");
// if (systemParamConfigEntity.getParamValue().equals("1")) {
// List<UdiCompanyEntity> mUdiCompanyEntities = new ArrayList<>();
// int page = 1;
// int limit = 300;
// while (true) {
// logger.info("更新时间:" + updateTime + "----" + page + "----" + limit);
// List<UdiCompanyEntity> udiCompanyEntities = asyncDiDlHelper.dlCompanyByTime(page, limit, updateTime);
// if (udiCompanyEntities != null && udiCompanyEntities.size() > 0) {
// mUdiCompanyEntities.addAll(udiCompanyEntities);
// if (udiCompanyEntities.size() < limit) {
// break;
// } else {
// page++;
// }
// } else {
// break;
// }
// }
// logger.info("更新时间:" + updateTime + "----" + "下载结束");
//
// SystemParamConfigEntity downstream = systemParamConfigService.selectByParamKey("sync_downstream_enable");
// String key = "UdiCompanys" + System.currentTimeMillis();
// String datas = JSON.toJSON(mUdiCompanyEntities).toString();
// if (downstream.getParamValue().equals("1")) {
// redisUtil.set(key, datas);
// BasicExportStatusEntity myEntity = new BasicExportStatusEntity();
// myEntity.setId(key);
// basicExportService.insertExportStatus(myEntity);
// } else {
// String path = getPath();
// String fileName = path + FileConstant.upWaitCopy_products + "UdiCompanys_" + key + ".LowerIn";
// FileUtils.SaveFileAs(datas, fileName);
// }
// }
}

Loading…
Cancel
Save