fix: 定时同步接口sql-inject

This commit is contained in:
fit2cloud-chenyw 2023-09-11 17:24:57 +08:00
parent f2a6166a8d
commit f5f3214271
19 changed files with 311 additions and 292 deletions

View File

@ -8,8 +8,8 @@ import io.dataease.commons.constants.DePermissionType;
import io.dataease.commons.constants.ResourceAuthLevel;
import io.dataease.commons.utils.PageUtils;
import io.dataease.commons.utils.Pager;
import io.dataease.controller.dataset.request.DatasetTaskGridRequest;
import io.dataease.controller.request.dataset.DataSetTaskRequest;
import io.dataease.controller.sys.base.BaseGridRequest;
import io.dataease.dto.dataset.DataSetTaskDTO;
import io.dataease.plugins.common.base.domain.DatasetTableTask;
import io.dataease.service.dataset.DataSetTableTaskLogService;
@ -77,7 +77,7 @@ public class DataSetTableTaskController {
@ApiOperation("分页查询")
@PostMapping("/pageList/{goPage}/{pageSize}")
public Pager<List<DataSetTaskDTO>> taskList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody BaseGridRequest request) {
public Pager<List<DataSetTaskDTO>> taskList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody DatasetTaskGridRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
Pager<List<DataSetTaskDTO>> listPager = PageUtils.setPageInfo(page, dataSetTableTaskService.taskList4User(request));

View File

@ -4,16 +4,15 @@ import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.dataease.auth.annotation.DePermission;
import io.dataease.plugins.common.base.domain.DatasetTableTaskLog;
import io.dataease.commons.constants.DePermissionType;
import io.dataease.commons.constants.ResourceAuthLevel;
import io.dataease.commons.utils.PageUtils;
import io.dataease.commons.utils.Pager;
import io.dataease.controller.sys.base.BaseGridRequest;
import io.dataease.controller.dataset.request.DataSetTaskInstanceGridRequest;
import io.dataease.dto.dataset.DataSetTaskLogDTO;
import io.dataease.plugins.common.base.domain.DatasetTableTaskLog;
import io.dataease.service.dataset.DataSetTableTaskLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
@ -41,14 +40,14 @@ public class DataSetTableTaskLogController {
@ApiOperation("分页查询")
@PostMapping("list/{type}/{goPage}/{pageSize}")
public Pager<List<DataSetTaskLogDTO>> list(@RequestBody BaseGridRequest request, @PathVariable String type, @PathVariable int goPage, @PathVariable int pageSize) {
public Pager<List<DataSetTaskLogDTO>> list(@RequestBody DataSetTaskInstanceGridRequest request, @PathVariable String type, @PathVariable int goPage, @PathVariable int pageSize) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, dataSetTableTaskLogService.listTaskLog(request, type));
}
@ApiOperation("分页查询")
@PostMapping("listForDataset/{type}/{goPage}/{pageSize}")
public Pager<List<DataSetTaskLogDTO>> listForDataset(@RequestBody BaseGridRequest request, @PathVariable String type, @PathVariable int goPage, @PathVariable int pageSize) {
public Pager<List<DataSetTaskLogDTO>> listForDataset(@RequestBody DataSetTaskInstanceGridRequest request, @PathVariable String type, @PathVariable int goPage, @PathVariable int pageSize) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, dataSetTableTaskLogService.listTaskLog(request, type));
}
@ -56,7 +55,7 @@ public class DataSetTableTaskLogController {
@ApiOperation("导出同步日志")
@PostMapping("export")
public void export(@RequestBody BaseGridRequest request) throws Exception{
public void export(@RequestBody DataSetTaskInstanceGridRequest request) throws Exception {
dataSetTableTaskLogService.exportExcel(request);
}

View File

@ -0,0 +1,20 @@
package io.dataease.controller.dataset.request;
import io.dataease.plugins.common.request.KeywordRequest;
import lombok.Data;
import java.util.List;
@Data
public class DataSetTaskInstanceGridRequest extends KeywordRequest {
private String id;
private List<String> lastExecStatus;
private Long[] lastExecTime;
private List<String> tableId;
private List<String> excludedIdList;
}

View File

@ -0,0 +1,22 @@
package io.dataease.controller.dataset.request;
import io.dataease.plugins.common.request.KeywordRequest;
import lombok.Data;
import java.util.List;
@Data
public class DatasetTaskGridRequest extends KeywordRequest {
private List<String> rate;
private List<String> status;
private List<String> lastExecStatus;
private List<String> tableId;
private Long[] lastExecTime;
private String id;
}

View File

@ -1,8 +1,9 @@
package io.dataease.ext;
import io.dataease.controller.dataset.request.DataSetTaskInstanceGridRequest;
import io.dataease.controller.dataset.request.DatasetTaskGridRequest;
import io.dataease.dto.dataset.DataSetTaskDTO;
import io.dataease.dto.dataset.DataSetTaskLogDTO;
import io.dataease.ext.query.GridExample;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -14,15 +15,15 @@ import java.util.List;
*/
@Mapper
public interface ExtDataSetTaskMapper {
List<DataSetTaskLogDTO> listTaskLog(GridExample example);
List<DataSetTaskLogDTO> listTaskLog(DataSetTaskInstanceGridRequest request);
List<DataSetTaskLogDTO> listUserTaskLog(GridExample example);
List<DataSetTaskLogDTO> listUserTaskLog(DataSetTaskInstanceGridRequest request);
List<DataSetTaskDTO> taskList(GridExample example);
List<DataSetTaskDTO> taskList(DatasetTaskGridRequest request);
List<DataSetTaskDTO> userTaskList(GridExample example);
List<DataSetTaskDTO> userTaskList(DatasetTaskGridRequest request);
List<DataSetTaskDTO> taskWithTriggers(GridExample example);
List<DataSetTaskDTO> taskWithTriggers(DatasetTaskGridRequest request);
List<DataSetTaskDTO> findByPanelId(@Param("panelId") String panelId);

View File

@ -21,15 +21,32 @@
FROM dataset_table_task_log
LEFT JOIN dataset_table_task ON dataset_table_task_log.task_id = dataset_table_task.id
LEFT JOIN dataset_table ON dataset_table_task_log.table_id = dataset_table.id
<if test="_parameter != null">
<include refid="io.dataease.ext.query.GridSql.gridCondition"/>
where 1=1
<if test="id != null">
and dataset_table_task.id = #{id}
</if>
<if test="orderByClause != null">
order by ${orderByClause}
<if test="lastExecStatus != null and lastExecStatus.size() > 0">
and dataset_table_task_log.status in
<foreach collection="lastExecStatus" open="(" close=")" separator="," item="status">
#{status}
</foreach>
</if>
<if test="orderByClause == null">
ORDER BY dataset_table_task_log.create_time desc
<if test="tableId != null and tableId.size() > 0">
and dataset_table.id in
<foreach collection="tableId" open="(" close=")" separator="," item="tid">
#{tid}
</foreach>
</if>
<if test="lastExecTime != null and lastExecTime.length > 1">
and (dataset_table_task.last_exec_time between #{lastExecTime.[0]} and #{lastExecTime.[1]})
</if>
<if test="keyword != null">
and dataset_table_task.name like concat('%', #{keyword}, '%')
</if>
ORDER BY dataset_table_task_log.create_time desc
</select>
<select id="listUserTaskLog" resultMap="BaseResult"
@ -38,82 +55,132 @@
FROM dataset_table_task_log
LEFT JOIN dataset_table_task ON dataset_table_task_log.task_id = dataset_table_task.id
LEFT JOIN dataset_table ON dataset_table_task_log.table_id = dataset_table.id
<if test="_parameter != null">
<include refid="io.dataease.ext.query.GridSql.taskListGridCondition"/>
where 1=1
<if test="id != null">
and dataset_table_task.id = #{id}
</if>
<if test="orderByClause != null">
order by ${orderByClause}
<if test="lastExecStatus != null and lastExecStatus.size() > 0">
and dataset_table_task_log.status in
<foreach collection="lastExecStatus" open="(" close=")" separator="," item="status">
#{status}
</foreach>
</if>
<if test="orderByClause == null">
ORDER BY dataset_table_task_log.create_time desc
<if test="tableId != null and tableId.size() > 0">
and dataset_table.id in
<foreach collection="tableId" open="(" close=")" separator="," item="tid">
#{tid}
</foreach>
</if>
<if test="lastExecTime != null and lastExecTime.length > 1">
and (dataset_table_task.last_exec_time between #{lastExecTime.[0]} and #{lastExecTime.[1]})
</if>
<if test="keyword != null">
and dataset_table_task.name like concat('%', #{keyword}, '%')
</if>
ORDER BY dataset_table_task_log.create_time desc
</select>
<select id="taskList" resultMap="TaskResult" parameterType="io.dataease.ext.query.GridExample">
<select id="taskList" resultMap="TaskResult" parameterType="io.dataease.controller.dataset.request.DatasetTaskGridRequest">
SELECT dataset_table.name as table_name, 'grant,manage,use' as `privileges`,dataset_table_task.* ,
qrtz_triggers.NEXT_FIRE_TIME
FROM dataset_table_task
left join dataset_table on dataset_table.id=dataset_table_task.table_id
left join qrtz_triggers on dataset_table_task.id=qrtz_triggers.TRIGGER_NAME
<if test="_parameter != null">
<include refid="io.dataease.ext.query.GridSql.gridCondition"/>
where 1=1
<if test="rate != null and rate.size() > 0">
and dataset_table_task.rate in
<foreach collection="rate" open="(" close=")" item="rateItem" separator=",">
#{rateItem}
</foreach>
</if>
<if test="orderByClause != null">
order by ${orderByClause}
<if test="status != null and status.size() > 0">
and dataset_table_task.status in
<foreach collection="status" open="(" close=")" item="statusItem" separator=",">
#{statusItem}
</foreach>
</if>
<if test="orderByClause == null">
order by dataset_table_task.create_time desc
<if test="lastExecStatus != null and lastExecStatus.size() > 0" >
and dataset_table_task.last_exec_status in
<foreach collection="lastExecStatus" open="(" close=")" item="lastExecStatusItem" separator=",">
#{lastExecStatusItem}
</foreach>
</if>
<if test="tableId != null and tableId.size() > 0">
and dataset_table.id in
<foreach collection="tableId" open="(" close=")" separator="," item="tid">
#{tid}
</foreach>
</if>
<if test="id != null">
and dataset_table_task.id = #{id}
</if>
<if test="lastExecTime != null and lastExecTime.length > 1">
and (dataset_table_task.last_exec_time between #{lastExecTime.[0]} and #{lastExecTime.[1]})
</if>
<if test="keyword != null">
and dataset_table_task.name like concat('%', #{keyword}, '%')
</if>
order by dataset_table_task.create_time desc
</select>
<select id="userTaskList" resultMap="TaskResult" parameterType="io.dataease.ext.query.GridExample">
<select id="userTaskList" resultMap="TaskResult" parameterType="io.dataease.controller.dataset.request.DatasetTaskGridRequest">
SELECT dataset_table.name as table_name, get_auths(dataset_table_task.table_id,'dataset', #{extendCondition}) as
`privileges`,dataset_table_task.* , qrtz_triggers.NEXT_FIRE_TIME
FROM dataset_table_task
left join dataset_table on dataset_table.id=dataset_table_task.table_id
left join qrtz_triggers on dataset_table_task.id=qrtz_triggers.TRIGGER_NAME
<if test="_parameter != null">
<include refid="io.dataease.ext.query.GridSql.taskListGridCondition"/>
where 1=1
<if test="rate != null and rate.size() > 0">
and dataset_table_task.rate in
<foreach collection="rate" open="(" close=")" item="rateItem" separator=",">
#{rateItem}
</foreach>
</if>
<if test="orderByClause != null">
order by ${orderByClause}
<if test="status != null and status.size() > 0">
and dataset_table_task.status in
<foreach collection="status" open="(" close=")" item="statusItem" separator=",">
#{statusItem}
</foreach>
</if>
<if test="orderByClause == null">
order by dataset_table_task.create_time desc
<if test="lastExecStatus != null and lastExecStatus.size() > 0">
and dataset_table_task.last_exec_status in
<foreach collection="lastExecStatus" open="(" close=")" item="lastExecStatusItem" separator=",">
#{lastExecStatusItem}
</foreach>
</if>
<if test="id != null">
and dataset_table_task.id = #{id}
</if>
<if test="tableId != null and tableId.size() > 0">
and dataset_table.id in
<foreach collection="tableId" open="(" close=")" separator="," item="tid">
#{tid}
</foreach>
</if>
<if test="lastExecTime != null and lastExecTime.length > 1">
and (dataset_table_task.last_exec_time between #{lastExecTime.[0]} and #{lastExecTime.[1]})
</if>
<if test="keyword != null">
and dataset_table_task.name like concat('%', #{keyword}, '%')
</if>
order by dataset_table_task.create_time desc
</select>
<select id="userTaskList_COUNT" resultType="LONG">
SELECT count(0)
FROM dataset_table_task
left join dataset_table on dataset_table.id=dataset_table_task.table_id
left join qrtz_triggers on dataset_table_task.id=qrtz_triggers.TRIGGER_NAME
<if test="_parameter != null">
<include refid="io.dataease.ext.query.GridSql.taskListGridCondition"/>
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
<if test="orderByClause == null">
order by dataset_table_task.create_time desc
</if>
</select>
<select id="taskWithTriggers" resultMap="TaskResult" parameterType="io.dataease.ext.query.GridExample">
<select id="taskWithTriggers" resultMap="TaskResult" parameterType="io.dataease.controller.dataset.request.DatasetTaskGridRequest">
SELECT dataset_table.name as table_name, get_auths(dataset_table_task.table_id,'dataset', #{extendCondition}) as
`privileges`,dataset_table_task.* , qrtz_triggers.NEXT_FIRE_TIME
FROM dataset_table_task
left join dataset_table on dataset_table.id=dataset_table_task.table_id
left join qrtz_triggers on dataset_table_task.id=qrtz_triggers.TRIGGER_NAME
<if test="_parameter != null">
<include refid="io.dataease.ext.query.GridSql.gridCondition"/>
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
<if test="orderByClause == null">
order by dataset_table_task.create_time desc
<if test="id != null">
and dataset_table_task.id = #{id}
</if>
order by dataset_table_task.create_time desc
</select>
<select id="findByPanelId" resultMap="TaskResult">

View File

@ -62,19 +62,16 @@ public class XEmailTaskServer {
@PostMapping("/queryTasks/{goPage}/{pageSize}")
@SqlInjectValidator(value = {"create_time"})
public Pager<List<XpackTaskGridDTO>> queryTask(@PathVariable int goPage, @PathVariable int pageSize,
@RequestBody XpackGridRequest request) {
@RequestBody XpackEmailTaskGridRequest request) {
EmailXpackService emailXpackService = SpringContextUtil.getBean(EmailXpackService.class);
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
CurrentUserDto user = AuthUtils.getUser();
if (!user.getIsAdmin()) {
Long userId = user.getUserId();
XpackConditionEntity condition = new XpackConditionEntity();
condition.setField("u.user_id");
condition.setOperator("eq");
condition.setValue(userId);
List<XpackConditionEntity> conditions = CollectionUtils.isEmpty(request.getConditions()) ? new ArrayList<>() : request.getConditions();
conditions.add(condition);
request.setConditions(conditions);
List<Long> userIdList = request.getUserIdList();
if (userIdList == null) {
userIdList = new ArrayList<>();
}
userIdList.add(user.getUserId());
}
List<XpackTaskGridDTO> tasks = emailXpackService.taskGrid(request);
@ -325,7 +322,7 @@ public class XEmailTaskServer {
@PostMapping("/queryInstancies/{goPage}/{pageSize}")
public Pager<List<XpackTaskInstanceDTO>> instancesGrid(@PathVariable int goPage, @PathVariable int pageSize,
@RequestBody XpackGridRequest request) {
@RequestBody XpackEmailInstanceGridRequest request) {
EmailXpackService emailXpackService = SpringContextUtil.getBean(EmailXpackService.class);
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
List<XpackTaskInstanceDTO> instances = emailXpackService.taskInstanceGrid(request);
@ -342,7 +339,7 @@ public class XEmailTaskServer {
@RequiresPermissions("task-email:read")
@PostMapping("/export")
public void export(@RequestBody XpackGridRequest request) throws Exception {
public void export(@RequestBody XpackEmailInstanceGridRequest request) throws Exception {
Pager<List<XpackTaskInstanceDTO>> listPager = instancesGrid(0, 0, request);
List<XpackTaskInstanceDTO> instanceDTOS = listPager.getListObject();
ExcelSheetModel excelSheetModel = excelSheetModel(instanceDTOS);

View File

@ -19,13 +19,12 @@ import io.dataease.commons.constants.*;
import io.dataease.commons.exception.DEException;
import io.dataease.commons.utils.*;
import io.dataease.controller.ResultHolder;
import io.dataease.controller.dataset.request.DataSetTaskInstanceGridRequest;
import io.dataease.controller.request.dataset.DataSetExportRequest;
import io.dataease.controller.request.dataset.DataSetGroupRequest;
import io.dataease.controller.request.dataset.DataSetTableRequest;
import io.dataease.controller.request.dataset.DataSetTaskRequest;
import io.dataease.controller.response.DataSetDetail;
import io.dataease.controller.sys.base.BaseGridRequest;
import io.dataease.controller.sys.base.ConditionEntity;
import io.dataease.dto.SysLogDTO;
import io.dataease.dto.dataset.*;
import io.dataease.dto.dataset.union.UnionDTO;
@ -794,14 +793,9 @@ public class DataSetTableService {
logger.error(e.getMessage());
DEException.throwException(Translator.get("i18n_ds_error") + "->" + e.getMessage());
}
BaseGridRequest request = new BaseGridRequest();
ConditionEntity entity2 = new ConditionEntity();
entity2.setField("dataset_table_task_log.table_id");
entity2.setOperator("eq");
entity2.setValue(dataSetTableRequest.getId());
List<ConditionEntity> conditionEntities = new ArrayList<>();
conditionEntities.add(entity2);
request.setConditions(conditionEntities);
DataSetTaskInstanceGridRequest request = new DataSetTaskInstanceGridRequest();
request.setTableId(List.of(dataSetTableRequest.getId()));
List<DataSetTaskLogDTO> dataSetTaskLogDTOS = dataSetTableTaskLogService.listTaskLog(request, "excel");
if (CollectionUtils.isNotEmpty(dataSetTaskLogDTOS)) {
dataSetTaskLogDTOS.get(0).getStatus().equalsIgnoreCase(JobStatus.Underway.name());
@ -2445,7 +2439,8 @@ public class DataSetTableService {
fields.add(tableFiled);
}
String json = JSON.toJSONString(noModelDataListener.getData());
List<List<String>> data = JSON.parseObject(json, new TypeReference< List<List<String>>>(){});
List<List<String>> data = JSON.parseObject(json, new TypeReference<List<List<String>>>() {
});
data = (isPreview && noModelDataListener.getData().size() > 1000 ? new ArrayList<>(data.subList(0, 1000)) : data);
if (isPreview) {
for (List<String> datum : data) {
@ -3103,51 +3098,52 @@ public class DataSetTableService {
}
@Data
public class NoModelDataListener extends AnalysisEventListener<Map<Integer, String>> {
private List<List<String>> data = new ArrayList<>();
private List<String> header = new ArrayList<>();
@Data
public class NoModelDataListener extends AnalysisEventListener<Map<Integer, String>> {
private List<List<String>> data = new ArrayList<>();
private List<String> header = new ArrayList<>();
@Override
public void invokeHead(Map<Integer, CellData> headMap, AnalysisContext context) {
super.invokeHead(headMap, context);
for (Integer key : headMap.keySet()) {
CellData cellData = headMap.get(key);
String value = cellData.getStringValue();
if (StringUtils.isEmpty(value)) {
value = "none_" + key;
}
header.add(value);
}
}
@Override
public void invoke(Map<Integer, String> dataMap, AnalysisContext context) {
List<String> line = new ArrayList<>();
for (Integer key : dataMap.keySet()) {
String value = dataMap.get(key);
if (StringUtils.isEmpty(value)) {
value = "";
}
line.add(value);
};
int size = line.size();
if(size < header.size()){
for (int i = 0; i < header.size() - size; i++) {
line.add("");
@Override
public void invokeHead(Map<Integer, CellData> headMap, AnalysisContext context) {
super.invokeHead(headMap, context);
for (Integer key : headMap.keySet()) {
CellData cellData = headMap.get(key);
String value = cellData.getStringValue();
if (StringUtils.isEmpty(value)) {
value = "none_" + key;
}
header.add(value);
}
}
data.add(line);
}
@Override
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
}
@Override
public void invoke(Map<Integer, String> dataMap, AnalysisContext context) {
List<String> line = new ArrayList<>();
for (Integer key : dataMap.keySet()) {
String value = dataMap.get(key);
if (StringUtils.isEmpty(value)) {
value = "";
}
line.add(value);
}
;
int size = line.size();
if (size < header.size()) {
for (int i = 0; i < header.size() - size; i++) {
line.add("");
}
}
data.add(line);
}
public void clear() {
data.clear();
header.clear();
@Override
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
}
public void clear() {
data.clear();
header.clear();
}
}
}
}

View File

@ -3,6 +3,7 @@ package io.dataease.service.dataset;
import cn.hutool.core.date.DateUtil;
import io.dataease.commons.constants.SysLogConstants;
import io.dataease.commons.utils.ServletUtils;
import io.dataease.controller.dataset.request.DataSetTaskInstanceGridRequest;
import io.dataease.exception.DataEaseException;
import io.dataease.ext.ExtDataSetTaskMapper;
import io.dataease.ext.query.GridExample;
@ -70,7 +71,7 @@ public class DataSetTableTaskLogService {
datasetTableTaskLogMapper.deleteByPrimaryKey(id);
}
public void exportExcel(BaseGridRequest request) throws Exception {
public void exportExcel(DataSetTaskInstanceGridRequest request) throws Exception {
HttpServletResponse response = ServletUtils.response();
OutputStream outputStream = response.getOutputStream();
try {
@ -137,38 +138,12 @@ public class DataSetTableTaskLogService {
}
public List<DataSetTaskLogDTO> listTaskLog(BaseGridRequest request, String type) {
List<ConditionEntity> conditionEntities = request.getConditions();
public List<DataSetTaskLogDTO> listTaskLog(DataSetTaskInstanceGridRequest request, String type) {
if(!type.equalsIgnoreCase("excel")){
ConditionEntity entity = new ConditionEntity();
entity.setField("task_id");
entity.setOperator("not in");
List<String>status = new ArrayList<>();status.add("初始导入");status.add("替换");status.add("追加");
entity.setValue(status);
if(CollectionUtils.isEmpty(conditionEntities)){
conditionEntities = new ArrayList<>();
}
conditionEntities.add(entity);
request.setExcludedIdList(List.of("初始导入", "替换", "追加"));
}
ConditionEntity entity2 = new ConditionEntity();
entity2.setField("1");
entity2.setOperator("eq");
entity2.setValue("1");
conditionEntities.add(entity2);
conditionEntities = conditionEntities.stream().map(conditionEntity -> {
if(conditionEntity.getField().equals("dataset_table_task.last_exec_status")){
conditionEntity.setField("dataset_table_task_log.status");
}
return conditionEntity;
}).collect(Collectors.toList());
request.setConditions(conditionEntities);
GridExample gridExample = request.convertExample();
gridExample.setExtendCondition(AuthUtils.getUser().getUserId().toString());
if(AuthUtils.getUser().getIsAdmin()){
List<DataSetTaskLogDTO> dataSetTaskLogDTOS = extDataSetTaskMapper.listTaskLog(gridExample);
List<DataSetTaskLogDTO> dataSetTaskLogDTOS = extDataSetTaskMapper.listTaskLog(request);
dataSetTaskLogDTOS.forEach(dataSetTaskLogDTO -> {
if(StringUtils.isEmpty(dataSetTaskLogDTO.getName())){
dataSetTaskLogDTO.setName(dataSetTaskLogDTO.getTaskId());
@ -176,7 +151,7 @@ public class DataSetTableTaskLogService {
});
return dataSetTaskLogDTOS;
}else {
List<DataSetTaskLogDTO> dataSetTaskLogDTOS = extDataSetTaskMapper.listUserTaskLog(gridExample);
List<DataSetTaskLogDTO> dataSetTaskLogDTOS = extDataSetTaskMapper.listUserTaskLog(request);
dataSetTaskLogDTOS.forEach(dataSetTaskLogDTO -> {
if(StringUtils.isEmpty(dataSetTaskLogDTO.getName())){
dataSetTaskLogDTO.setName(dataSetTaskLogDTO.getTaskId());

View File

@ -1,17 +1,15 @@
package io.dataease.service.dataset;
import io.dataease.ext.ExtDataSetTaskMapper;
import io.dataease.ext.query.GridExample;
import io.dataease.commons.constants.JobStatus;
import io.dataease.commons.constants.ScheduleType;
import io.dataease.commons.constants.TaskStatus;
import io.dataease.commons.constants.TriggerType;
import io.dataease.commons.utils.AuthUtils;
import io.dataease.controller.dataset.request.DatasetTaskGridRequest;
import io.dataease.controller.request.dataset.DataSetTaskRequest;
import io.dataease.controller.sys.base.BaseGridRequest;
import io.dataease.controller.sys.base.ConditionEntity;
import io.dataease.dto.dataset.DataSetTaskDTO;
import io.dataease.exception.DataEaseException;
import io.dataease.ext.ExtDataSetTaskMapper;
import io.dataease.i18n.Translator;
import io.dataease.plugins.common.base.domain.*;
import io.dataease.plugins.common.base.mapper.DatasetTableMapper;
@ -24,10 +22,10 @@ import org.quartz.CronExpression;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PathVariable;
import javax.annotation.Resource;
import java.util.*;
import java.util.List;
import java.util.UUID;
/**
* @Author gin
@ -152,7 +150,7 @@ public class DataSetTableTaskService {
@Transactional
public void batchDelete(List<String> ids) {
if (CollectionUtils.isNotEmpty(ids)){
if (CollectionUtils.isNotEmpty(ids)) {
for (int i = 0; i < ids.size(); i++) {
String id = ids.get(i);
DatasetTableTask datasetTableTask = datasetTableTaskMapper.selectByPrimaryKey(id);
@ -195,12 +193,9 @@ public class DataSetTableTaskService {
public void checkTaskIsStopped(final DatasetTableTask datasetTableTask) {
if (StringUtils.isNotEmpty(datasetTableTask.getEnd()) && datasetTableTask.getEnd().equalsIgnoreCase("1")) {
BaseGridRequest request = new BaseGridRequest();
ConditionEntity conditionEntity = new ConditionEntity();
conditionEntity.setField("dataset_table_task.id");
conditionEntity.setOperator("eq");
conditionEntity.setValue(datasetTableTask.getId());
request.setConditions(Collections.singletonList(conditionEntity));
DatasetTaskGridRequest request = new DatasetTaskGridRequest();
request.setId(datasetTableTask.getId());
List<DataSetTaskDTO> dataSetTaskDTOS = taskWithTriggers(request);
if (CollectionUtils.isEmpty(dataSetTaskDTOS)) {
return;
@ -231,12 +226,8 @@ public class DataSetTableTaskService {
} else {
recore.setLastExecStatus(lastExecStatus.name());
if (StringUtils.isNotEmpty(datasetTableTask.getEnd()) && datasetTableTask.getEnd().equalsIgnoreCase("1")) {
BaseGridRequest request = new BaseGridRequest();
ConditionEntity conditionEntity = new ConditionEntity();
conditionEntity.setField("dataset_table_task.id");
conditionEntity.setOperator("eq");
conditionEntity.setValue(datasetTableTask.getId());
request.setConditions(Collections.singletonList(conditionEntity));
DatasetTaskGridRequest request = new DatasetTaskGridRequest();
request.setId(datasetTableTask.getId());
List<DataSetTaskDTO> dataSetTaskDTOS = taskWithTriggers(request);
if (CollectionUtils.isEmpty(dataSetTaskDTOS)) {
return;
@ -264,40 +255,24 @@ public class DataSetTableTaskService {
}
public List<DataSetTaskDTO> list(DatasetTableTask datasetTableTask) {
BaseGridRequest request = new BaseGridRequest();
List<ConditionEntity> conditionEntities = new ArrayList<>();
if(datasetTableTask != null && StringUtils.isNotEmpty(datasetTableTask.getTableId())){
ConditionEntity entity = new ConditionEntity();
entity.setField("table_id");
entity.setOperator("eq");
entity.setValue(datasetTableTask.getTableId());
conditionEntities.add(entity);
DatasetTaskGridRequest request = new DatasetTaskGridRequest();
if (datasetTableTask != null && StringUtils.isNotEmpty(datasetTableTask.getTableId())) {
request.setTableId(List.of(datasetTableTask.getTableId()));
}
request.setConditions(conditionEntities);
GridExample gridExample = request.convertExample();
return extDataSetTaskMapper.taskList(gridExample);
return extDataSetTaskMapper.taskList(request);
}
public List<DataSetTaskDTO> taskList4User(BaseGridRequest request) {
List<ConditionEntity> conditionEntities = request.getConditions() == null ? new ArrayList<>() : new ArrayList(request.getConditions());
ConditionEntity entity = new ConditionEntity();
entity.setField("1");
entity.setOperator("eq");
entity.setValue("1");
conditionEntities.add(entity);
request.setConditions(conditionEntities);
GridExample gridExample = request.convertExample();
gridExample.setExtendCondition(AuthUtils.getUser().getUserId().toString());
public List<DataSetTaskDTO> taskList4User(DatasetTaskGridRequest request) {
if (AuthUtils.getUser().getIsAdmin()) {
return extDataSetTaskMapper.taskList(gridExample);
return extDataSetTaskMapper.taskList(request);
} else {
return extDataSetTaskMapper.userTaskList(gridExample);
return extDataSetTaskMapper.userTaskList(request);
}
}
public List<DataSetTaskDTO> taskWithTriggers(BaseGridRequest request) {
GridExample gridExample = request.convertExample();
return extDataSetTaskMapper.taskWithTriggers(gridExample);
public List<DataSetTaskDTO> taskWithTriggers(DatasetTaskGridRequest request) {
return extDataSetTaskMapper.taskWithTriggers(request);
}
private void checkName(DataSetTaskRequest dataSetTaskRequest) {
@ -335,7 +310,7 @@ public class DataSetTableTaskService {
public void execTask(DatasetTableTask datasetTableTask) throws Exception {
execNow(datasetTableTask);
if(datasetTableTask.getRate().equalsIgnoreCase(ScheduleType.SIMPLE.toString())){
if (datasetTableTask.getRate().equalsIgnoreCase(ScheduleType.SIMPLE.toString())) {
scheduleService.addSchedule(datasetTableTask);
}
if (!datasetTableTask.getRate().equalsIgnoreCase(ScheduleType.SIMPLE.toString())) {
@ -344,16 +319,9 @@ public class DataSetTableTaskService {
}
public DataSetTaskDTO detail(String id) {
BaseGridRequest request = new BaseGridRequest();
List<ConditionEntity> conditionEntities = request.getConditions() == null ? new ArrayList<>() : new ArrayList(request.getConditions());
ConditionEntity entity = new ConditionEntity();
entity.setField("dataset_table_task.id");
entity.setOperator("eq");
entity.setValue(id);
conditionEntities.add(entity);
request.setConditions(conditionEntities);
GridExample gridExample = request.convertExample();
List<DataSetTaskDTO> dataSetTaskDTOS = extDataSetTaskMapper.taskList(gridExample);
DatasetTaskGridRequest request = new DatasetTaskGridRequest();
request.setId(id);
List<DataSetTaskDTO> dataSetTaskDTOS = extDataSetTaskMapper.taskList(request);
if (CollectionUtils.isNotEmpty(dataSetTaskDTOS)) {
return dataSetTaskDTOS.get(0);
}

View File

@ -1048,14 +1048,7 @@ export default {
},
listTaskLog(loading = true) {
const params = {
conditions: [
{
field: 'dataset_table_task_log.table_id',
operator: 'eq',
value: this.table.id
}
],
orders: []
tableId: [this.table.id]
}
post(
'/dataset/taskLog/listForDataset/' +

View File

@ -866,7 +866,7 @@ export default {
}
},
listTaskLog(loading = true) {
const params = { 'conditions': [{ 'field': 'dataset_table_task_log.table_id', 'operator': 'eq', 'value': this.table.id }], 'orders': [] }
const params = { 'tableId': [this.table.id], 'orders': [] }
post('/dataset/taskLog/listForDataset/' + this.table.type + '/' + this.page.currentPage + '/' + this.page.pageSize, params, loading).then(response => {
this.taskLogData = response.data.listObject
this.page.total = response.data.itemCount

View File

@ -350,7 +350,7 @@ import filterUser from './FilterUser.vue'
import msgCfm from '@/components/msgCfm/index'
import _ from 'lodash'
import keyEnter from '@/components/msgCfm/keyEnter.js'
import { buildParam } from '@/utils/GridConditionUtil'
export default {
name: 'DatasetTaskList',
components: { GridTable, filterUser },
@ -502,23 +502,12 @@ export default {
},
search(showLoading = true) {
const { taskId, name } = this.transCondition
const param = {
orders: formatOrders(this.orderConditions),
conditions: [...this.cacheCondition]
}
if (this.nickName) {
param.conditions.push({
field: `dataset_table_task.name`,
operator: 'like',
value: this.nickName
})
}
const param = buildParam(this.cacheCondition, this.nickName)
param.orders = formatOrders(this.orderConditions)
if (taskId && this.nickName === name) {
param.conditions.push({
operator: 'eq',
value: taskId,
field: 'dataset_table_task.id'
})
param['id'] = taskId
}
const { currentPage, pageSize } = this.paginationConfig
datasetTaskList(currentPage, pageSize, param, showLoading).then(

View File

@ -315,7 +315,7 @@ export default {
'dataset_table_task.rate': this.active.rate,
'dataset_table_task.status': this.active.status,
'dataset_table_task.last_exec_status': this.active.execStatus,
'dataset_table.id': this.activeDataset
'dataset_table.tableId': this.activeDataset
}
const conditions = []
Object.keys(fildMap).forEach((ele) => {

View File

@ -308,7 +308,7 @@ export default {
formatCondition() {
const fildMap = {
'dataset_table_task.last_exec_status': this.active.execStatus,
'dataset_table.id': this.activeDataset
'dataset_table.tableId': this.activeDataset
}
const conditions = []
Object.keys(fildMap).forEach((ele) => {

View File

@ -179,7 +179,7 @@ import GridTable from '@/components/gridTable/index.vue'
import filterUser from './FilterUserRecord.vue'
import _ from 'lodash'
import keyEnter from '@/components/msgCfm/keyEnter.js'
import { buildParam } from '@/utils/GridConditionUtil'
export default {
name: 'TaskRecord',
components: { GridTable, filterUser },
@ -258,23 +258,10 @@ export default {
},
exportData() {
const { taskId, name } = this.transCondition
const param = {
orders: formatOrders(this.orderConditions),
conditions: [...this.cacheCondition]
}
if (this.nickName) {
param.conditions.push({
field: `dataset_table_task.name`,
operator: 'like',
value: this.nickName
})
}
const param = buildParam(this.cacheCondition, this.nickName)
param.orders = formatOrders(this.orderConditions)
if (taskId && this.nickName === name) {
param.conditions.push({
operator: 'eq',
value: taskId,
field: 'dataset_table_task.id'
})
param.id = taskId
}
exportExcel(param).then((res) => {
const blob = new Blob([res], { type: 'application/vnd.ms-excel' })
@ -368,23 +355,10 @@ export default {
this.lastRequestComplete = false
}
const { taskId, name } = this.transCondition
const param = {
orders: formatOrders(this.orderConditions),
conditions: [...this.cacheCondition]
}
if (this.nickName) {
param.conditions.push({
field: `dataset_table_task.name`,
operator: 'like',
value: this.nickName
})
}
const param = buildParam(this.cacheCondition, this.nickName)
param.orders = formatOrders(this.orderConditions)
if (taskId && this.nickName === name) {
param.conditions.push({
operator: 'eq',
value: taskId,
field: 'dataset_table_task.id'
})
param.id = taskId
}
post(
'/dataset/taskLog/list/notexcel/' +
@ -405,23 +379,10 @@ export default {
},
search(condition, showLoading = true) {
const { taskId, name } = this.transCondition
const param = {
orders: formatOrders(this.orderConditions),
conditions: [...this.cacheCondition]
}
if (this.nickName) {
param.conditions.push({
field: `dataset_table_task.name`,
operator: 'like',
value: this.nickName
})
}
const param = buildParam(this.cacheCondition, this.nickName)
param.orders = formatOrders(this.orderConditions)
if (taskId && this.nickName === name) {
param.conditions.push({
operator: 'eq',
value: taskId,
field: 'dataset_table_task.id'
})
param.id = taskId
}
post(
'/dataset/taskLog/list/notexcel/' +

View File

@ -0,0 +1,16 @@
package io.dataease.plugins.xpack.email.dto.request;
import io.dataease.plugins.common.request.KeywordRequest;
import lombok.Data;
import java.util.List;
@Data
public class XpackEmailInstanceGridRequest extends KeywordRequest {
private List<String> statusList;
private Long[] timeArray;
private Long taskId;
}

View File

@ -0,0 +1,13 @@
package io.dataease.plugins.xpack.email.dto.request;
import lombok.Data;
import java.util.List;
@Data
public class XpackEmailTaskGridRequest extends XpackEmailInstanceGridRequest {
private List<Long> userIdList;
}

View File

@ -6,6 +6,8 @@ import io.dataease.plugins.common.entity.GlobalTaskEntity;
import io.dataease.plugins.common.entity.GlobalTaskInstance;
import io.dataease.plugins.common.entity.XpackGridRequest;
import io.dataease.plugins.common.service.PluginMenuService;
import io.dataease.plugins.xpack.email.dto.request.XpackEmailInstanceGridRequest;
import io.dataease.plugins.xpack.email.dto.request.XpackEmailTaskGridRequest;
import io.dataease.plugins.xpack.email.dto.request.XpackEmailTaskRequest;
import io.dataease.plugins.xpack.email.dto.request.XpackPixelEntity;
import io.dataease.plugins.xpack.email.dto.response.XpackEmailTemplateDTO;
@ -17,11 +19,11 @@ public abstract class EmailXpackService extends PluginMenuService {
public abstract int save(XpackEmailTaskRequest request) throws Exception;
public abstract List<XpackTaskGridDTO> taskGrid(XpackGridRequest request);
public abstract List<XpackTaskGridDTO> taskGrid(XpackEmailTaskGridRequest request);
public abstract Boolean status(GlobalTaskEntity taskEntity);
public abstract List<XpackTaskInstanceDTO> taskInstanceGrid(XpackGridRequest request);
public abstract List<XpackTaskInstanceDTO> taskInstanceGrid(XpackEmailInstanceGridRequest request);
public abstract void delete(Long taskId) throws Exception;