mirror of
https://gitee.com/devlive-community/datacap.git
synced 2024-12-02 20:17:45 +08:00
[Core] [Query] Fixed history data is null
This commit is contained in:
parent
3980c2d59e
commit
390960c185
@ -165,3 +165,6 @@ ALTER TABLE `datacap_dataset_history`
|
||||
UPDATE `datacap_dataset_history`
|
||||
SET `code` = REPLACE(UUID(), '-', '')
|
||||
WHERE `code` IS NULL;
|
||||
|
||||
ALTER TABLE `datacap_source_query`
|
||||
ADD COLUMN `home` VARCHAR(500);
|
||||
|
@ -24,9 +24,9 @@ public class PluginAuditController
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
@GetMapping(value = "data/{id}")
|
||||
public CommonResponse<Object> getData(@PathVariable Long id)
|
||||
@GetMapping(value = "data/{code}")
|
||||
public CommonResponse<Object> getData(@PathVariable String code)
|
||||
{
|
||||
return service.getData(id);
|
||||
return service.getData(code);
|
||||
}
|
||||
}
|
||||
|
@ -96,7 +96,8 @@ public class AuditPluginHandler
|
||||
this.pluginAuditRepository.save(pluginAudit);
|
||||
ExecutorService service = Executors.newSingleThreadExecutor();
|
||||
service.submit(() -> {
|
||||
String workHome = FolderUtils.getWorkHome(initializer.getDataHome(), user.getUsername(), String.join(File.separator, "adhoc", pluginAudit.getId().toString()));
|
||||
String uniqueId = !pluginAudit.getCode().isEmpty() ? pluginAudit.getCode() : pluginAudit.getId().toString();
|
||||
String workHome = FolderUtils.getWorkHome(initializer.getDataHome(), user.getUsername(), String.join(File.separator, "adhoc", uniqueId));
|
||||
log.info("Writer file to folder [ {} ] on [ {} ]", workHome, pluginAudit.getId());
|
||||
try {
|
||||
File tempFile = CSVUtils.makeTempCSV(workHome, "result.csv", jsonResult.getData().getHeaders(), jsonResult.getData().getColumns());
|
||||
@ -112,12 +113,14 @@ public class AuditPluginHandler
|
||||
.map(v -> v.writer(fsRequest));
|
||||
log.info("Delete temp file [ {} ] on [ {} ] statue [ {} ]", tempFile, pluginAudit.getId(), tempFile.delete());
|
||||
log.info("Writer file to folder [ {} ] on [ {} ] completed", workHome, pluginAudit.getId());
|
||||
pluginAudit.setHome(workHome);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
log.error("Writer file to folder [ {} ] on [ {} ] failed", workHome, pluginAudit.getId(), ex);
|
||||
}
|
||||
finally {
|
||||
service.shutdownNow();
|
||||
pluginAuditRepository.save(pluginAudit);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -20,6 +20,6 @@ public class FolderUtils
|
||||
*/
|
||||
public static String getWorkHome(String dataHome, String userName, String type)
|
||||
{
|
||||
return String.join(File.separator, dataHome, DateUtils.formatYMD(), userName, type);
|
||||
return String.join(File.separator, dataHome, userName, DateUtils.formatYMD(), type);
|
||||
}
|
||||
}
|
||||
|
@ -49,6 +49,9 @@ public class PluginAuditEntity
|
||||
@Column(name = "code")
|
||||
private String code;
|
||||
|
||||
@Column(name = "home")
|
||||
private String home;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "plugin_id")
|
||||
@JsonIncludeProperties(value = {"id", "name", "type", "code"})
|
||||
|
@ -18,5 +18,5 @@ public interface PluginAuditService
|
||||
|
||||
CommonResponse<PluginAuditEntity> getById(Long id);
|
||||
|
||||
CommonResponse<Object> getData(Long id);
|
||||
CommonResponse<Object> getData(String code);
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ import io.edurt.datacap.fs.FsResponse;
|
||||
import io.edurt.datacap.service.activity.HeatmapActivity;
|
||||
import io.edurt.datacap.service.adapter.PageRequestAdapter;
|
||||
import io.edurt.datacap.service.body.FilterBody;
|
||||
import io.edurt.datacap.service.common.FolderUtils;
|
||||
import io.edurt.datacap.service.entity.PageEntity;
|
||||
import io.edurt.datacap.service.entity.PluginAuditEntity;
|
||||
import io.edurt.datacap.service.entity.UserEntity;
|
||||
@ -25,7 +24,6 @@ import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.InputStreamReader;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
@ -97,16 +95,15 @@ public class PluginAuditServiceImpl
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResponse<Object> getData(Long id)
|
||||
public CommonResponse<Object> getData(String code)
|
||||
{
|
||||
return this.pluginAuditRepository.findById(id)
|
||||
return this.pluginAuditRepository.findByCode(code)
|
||||
.map(value -> {
|
||||
Response response = new Response();
|
||||
String workHome = FolderUtils.getWorkHome(initializer.getDataHome(), value.getUser().getUsername(), String.join(File.separator, "adhoc", id.toString()));
|
||||
FsRequest fsRequest = FsRequest.builder()
|
||||
.access(initializer.getFsConfigure().getAccess())
|
||||
.secret(initializer.getFsConfigure().getSecret())
|
||||
.endpoint(workHome)
|
||||
.endpoint(value.getHome())
|
||||
.bucket(initializer.getFsConfigure().getBucket())
|
||||
.fileName("result.csv")
|
||||
.build();
|
||||
@ -131,10 +128,10 @@ public class PluginAuditServiceImpl
|
||||
response.setColumns(columns);
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.warn("Reader cache failed on [ {} ]", id, e);
|
||||
log.warn("Reader cache failed on [ {} ]", code, e);
|
||||
}
|
||||
return CommonResponse.success(response);
|
||||
})
|
||||
.orElseGet(() -> CommonResponse.failure(String.format("Not found [ %s ] history", id)));
|
||||
.orElseGet(() -> CommonResponse.failure(String.format("Not found [ %s ] history", code)));
|
||||
}
|
||||
}
|
||||
|
@ -10,4 +10,5 @@ export interface HistoryModel
|
||||
count?: number
|
||||
mode?: string
|
||||
plugin?: any
|
||||
code?: string
|
||||
}
|
@ -18,9 +18,9 @@ class AuditService
|
||||
return new HttpUtils().post(`${ DEFAULT_PATH }`, filter)
|
||||
}
|
||||
|
||||
getData(id: number): Promise<ResponseModel>
|
||||
getData(code: string): Promise<ResponseModel>
|
||||
{
|
||||
return new HttpUtils().get(`${ DEFAULT_PATH }/data/${ id }`)
|
||||
return new HttpUtils().get(`${ DEFAULT_PATH }/data/${ code }`)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,6 @@ import Button from '@/views/ui/button'
|
||||
import { HistoryModel } from '@/model/history'
|
||||
import CircularLoading from '@/views/components/loading/CircularLoading.vue'
|
||||
import AuditService from '@/services/audit'
|
||||
import { toNumber } from 'lodash'
|
||||
import { Configuration, ConfigurationRequest } from '@/views/components/visual/Configuration'
|
||||
import VisualTable from '@/views/components/visual/components/VisualTable.vue'
|
||||
|
||||
@ -69,7 +68,7 @@ export default defineComponent({
|
||||
if (this.info) {
|
||||
this.title = `${ this.$t('query.common.historyDataInfo').replace('$VALUE', this.info.id as unknown as string) }`
|
||||
this.loading = true
|
||||
AuditService.getData(toNumber(this.info.id))
|
||||
AuditService.getData(this.info.code as string)
|
||||
.then(response => {
|
||||
if (response.status) {
|
||||
this.configuration = ConfigurationRequest.of(response)
|
||||
|
Loading…
Reference in New Issue
Block a user