空数据不写入问题

dev
anthonywj 8 months ago
parent 2336637294
commit 4d2ec8c834

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

@ -290,30 +290,43 @@ public class DlAllDataService {
idcService.batchDownloadFile(spGetHttp.getSpmsUrl(), list.toArray(new String[list.size()])); idcService.batchDownloadFile(spGetHttp.getSpmsUrl(), list.toArray(new String[list.size()]));
} }
if (StrUtil.isNotBlank(bean.getTaskId())) { if (StrUtil.isNotBlank(bean.getTaskId())) {
// 将数据写入文件 if (StrUtil.isNotBlank(bean.getFileContent()) && !bean.getFileContent().contains("系统繁忙")) {
// try { FileUtils.makeDirectory(filePath + "sync/");
FileUtils.makeDirectory(filePath + "sync/"); String fileName = filePath + "sync/" + exportType.getRemark() + "-" + bean.getTaskId() + ".udi";
String fileName = filePath + "sync/" + exportType.getRemark() + "-" + bean.getTaskId() + ".udi"; FileUtils.SaveFileAs(bean.getFileContent(), fileName);
FileUtils.SaveFileAs(bean.getFileContent(), fileName); BasicExportStatusEntity exportStatusEntity = BasicExportStatusEntity.builder()
// } catch (IOException e) { .id(bean.getTaskId())
// log.error("从UDI自助平台拉取基础数据 文件[{}]写入异常----{}",bean.getFilePath(), e.getMessage()); .taskId(bean.getTaskId())
// throw new RuntimeException(e); .status(BasicExportStatusEnum.WAIT_SYNC.getCode())
// } .type(exportType.getRemark())
BasicExportStatusEntity exportStatusEntity = BasicExportStatusEntity.builder() .transportType(1)
.id(bean.getTaskId()) .scheduleType(1)
.taskId(bean.getTaskId()) .fromType(1).remark(remark)
.status(BasicExportStatusEnum.WAIT_SYNC.getCode()) .startTime(DateUtil.getDateTime())
.type(exportType.getRemark()) .updateTime(new Date())
.transportType(1) .cacheFilePath(fileName)
.scheduleType(1) .build();
.fromType(1).remark(remark) basicExportService.insertExportStatus(exportStatusEntity);
.startTime(DateUtil.getDateTime()) //通知自助平台任务已完成
.updateTime(new Date()) spGetHttp.finishTask(bean.getTaskId());
.cacheFilePath(fileName) } else {
.build(); BasicExportStatusEntity exportStatusEntity = BasicExportStatusEntity.builder()
basicExportService.insertExportStatus(exportStatusEntity); .id(bean.getTaskId())
//通知自助平台任务已完成 .taskId(bean.getTaskId())
spGetHttp.finishTask(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; 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.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.param.SystemParamConfigService;
import com.glxp.sale.admin.service.sync.BasicExportService; import com.glxp.sale.admin.service.sync.BasicExportService;
import com.glxp.sale.admin.util.FileUtils;
import com.glxp.sale.admin.util.RedisUtil; import com.glxp.sale.admin.util.RedisUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; 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.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
@Service @Service
public class AsyncCompanyDlService { public class AsyncCompanyDlService {
@ -41,41 +32,41 @@ public class AsyncCompanyDlService {
@Async @Async
public void asyncDiByTime(String updateTime) { public void asyncDiByTime(String updateTime) {
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("sync_upstream_enable"); // SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("sync_upstream_enable");
if (systemParamConfigEntity.getParamValue().equals("1")) { // if (systemParamConfigEntity.getParamValue().equals("1")) {
List<UdiCompanyEntity> mUdiCompanyEntities = new ArrayList<>(); // List<UdiCompanyEntity> mUdiCompanyEntities = new ArrayList<>();
int page = 1; // int page = 1;
int limit = 300; // int limit = 300;
while (true) { // while (true) {
logger.info("更新时间:" + updateTime + "----" + page + "----" + limit); // logger.info("更新时间:" + updateTime + "----" + page + "----" + limit);
List<UdiCompanyEntity> udiCompanyEntities = asyncDiDlHelper.dlCompanyByTime(page, limit, updateTime); // List<UdiCompanyEntity> udiCompanyEntities = asyncDiDlHelper.dlCompanyByTime(page, limit, updateTime);
if (udiCompanyEntities != null && udiCompanyEntities.size() > 0) { // if (udiCompanyEntities != null && udiCompanyEntities.size() > 0) {
mUdiCompanyEntities.addAll(udiCompanyEntities); // mUdiCompanyEntities.addAll(udiCompanyEntities);
if (udiCompanyEntities.size() < limit) { // if (udiCompanyEntities.size() < limit) {
break; // break;
} else { // } else {
page++; // page++;
} // }
} else { // } else {
break; // break;
} // }
} // }
logger.info("更新时间:" + updateTime + "----" + "下载结束"); // logger.info("更新时间:" + updateTime + "----" + "下载结束");
//
SystemParamConfigEntity downstream = systemParamConfigService.selectByParamKey("sync_downstream_enable"); // SystemParamConfigEntity downstream = systemParamConfigService.selectByParamKey("sync_downstream_enable");
String key = "UdiCompanys" + System.currentTimeMillis(); // String key = "UdiCompanys" + System.currentTimeMillis();
String datas = JSON.toJSON(mUdiCompanyEntities).toString(); // String datas = JSON.toJSON(mUdiCompanyEntities).toString();
if (downstream.getParamValue().equals("1")) { // if (downstream.getParamValue().equals("1")) {
redisUtil.set(key, datas); // redisUtil.set(key, datas);
BasicExportStatusEntity myEntity = new BasicExportStatusEntity(); // BasicExportStatusEntity myEntity = new BasicExportStatusEntity();
myEntity.setId(key); // myEntity.setId(key);
basicExportService.insertExportStatus(myEntity); // basicExportService.insertExportStatus(myEntity);
} else { // } else {
String path = getPath(); // String path = getPath();
String fileName = path + FileConstant.upWaitCopy_products + "UdiCompanys_" + key + ".LowerIn"; // String fileName = path + FileConstant.upWaitCopy_products + "UdiCompanys_" + key + ".LowerIn";
FileUtils.SaveFileAs(datas, fileName); // FileUtils.SaveFileAs(datas, fileName);
} // }
} // }
} }

Loading…
Cancel
Save