上传及下载写入文件

master
wj 3 years ago
parent 655ecb508c
commit c85d0f445d

@ -1,10 +1,14 @@
package com.glxp.api.entity.sync;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.util.Date;
@Data
@TableName("basic_download_status")
public class BasicDownloadStatusEntity {
/**
@ -24,4 +28,6 @@ public class BasicDownloadStatusEntity {
private Date startTime;
private Date endTime;
private String remark;
@TableField(value = "cacheFilePath")
private String cacheFilePath;
}

@ -17,7 +17,6 @@ import lombok.NoArgsConstructor;
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class BasicExportStatusEntity {
@TableId(type = IdType.INPUT)

@ -49,6 +49,7 @@ import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.TransactionIsolationLevel;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
@ -864,7 +865,7 @@ public class HeartService {
* @return
*/
private SpsSyncSysSettingResponse getSysSettingData(SyncDataSetEntity info, String taskId, Date now, Date syncTime) {
SpsSyncSysSettingResponse dataResponse = null;
SpsSyncSysSettingResponse dataResponse = null;
Map<String, Object> syncTimeMap = new WeakHashMap<>(3);
syncTimeMap.put("isNew", true);
syncTimeMap.put("oldDate", syncTime);
@ -1059,7 +1060,14 @@ public class HeartService {
.scheduleType(BasicProcessStatus.SCHEDULE_NORMAL)
.remark(baseResponse.getMessage())
.build();
applicationContext.getBean(this.getClass()).insertExportStatus(exportStatus);
try {
String fileFullPath = writeFile(filePrefix, exportType.getRemark(), JsonUtils.toJsonString(data));
exportStatus.setCacheFilePath(fileFullPath);
} catch (IOException e) {
throw new RuntimeException(e);
}finally {
applicationContext.getBean(this.getClass()).insertExportStatus(exportStatus);
}
if (baseResponse.getCode() != 20000) {
throw new RuntimeException(baseResponse.getMessage());
}
@ -1412,6 +1420,8 @@ public class HeartService {
private final SupManufacturerDao supManufacturerDao;
private final SupProductDao supProductDao;
@Value("${file_path}")
private String filePrefix;
/**
* UDI
@ -1458,6 +1468,12 @@ public class HeartService {
basicDownloadStatusEntity.setStatus(BasicExportStatusEnum.SUCCESS.getCode()); //下载完成
basicDownloadStatusEntity.setType(exportType.getRemark());
basicDownloadStatusEntity.setScheduleType(1);
try {
String fileFullPath = writeFile(filePrefix, exportType.getRemark(), bean.getFileContent());
basicDownloadStatusEntity.setCacheFilePath(fileFullPath);
} catch (IOException e) {
throw new RuntimeException(e);
}
basicDownloadService.insertDownloadStatus(basicDownloadStatusEntity);
//通知自助平台任务已完成
spGetHttp.finishTask(taskId);

Loading…
Cancel
Save