From e500c960231ad348db777ae1992337a0ad509a67 Mon Sep 17 00:00:00 2001 From: "1437892690@qq.com" <1437892690@qq.com> Date: Wed, 31 Jul 2024 21:28:27 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20=E5=90=8E=E7=AB=AF-?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E4=BB=93=E5=BA=93=E5=90=8C=E6=AD=A5=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E4=BA=BA=E5=B7=A5=E5=B9=B2=E9=A2=84=E7=BB=88=E6=AD=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1213114991738880]后端-数据仓库同步支持人工干预终止 http://192.168.0.96:8090/demo/rdm.html#/task-detail/939050947543040/939050947543050/1213114991738880 --- .../datawarehouse/ActiveDataSourceApi.java | 97 +++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 src/main/java/neatlogic/module/tenant/api/datawarehouse/ActiveDataSourceApi.java diff --git a/src/main/java/neatlogic/module/tenant/api/datawarehouse/ActiveDataSourceApi.java b/src/main/java/neatlogic/module/tenant/api/datawarehouse/ActiveDataSourceApi.java new file mode 100644 index 00000000..4790be94 --- /dev/null +++ b/src/main/java/neatlogic/module/tenant/api/datawarehouse/ActiveDataSourceApi.java @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2024 深圳极向量科技有限公司 All Rights Reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package neatlogic.module.tenant.api.datawarehouse; + +import com.alibaba.fastjson.JSONObject; +import neatlogic.framework.auth.core.AuthAction; +import neatlogic.framework.auth.label.DATA_WAREHOUSE_MODIFY; +import neatlogic.framework.common.constvalue.ApiParamType; +import neatlogic.framework.datawarehouse.dao.mapper.DataWarehouseDataSourceMapper; +import neatlogic.framework.datawarehouse.dto.DataSourceVo; +import neatlogic.framework.datawarehouse.enums.Status; +import neatlogic.framework.datawarehouse.exceptions.DataSourceIsNotFoundException; +import neatlogic.framework.datawarehouse.service.DataSourceService; +import neatlogic.framework.restful.annotation.Description; +import neatlogic.framework.restful.annotation.Input; +import neatlogic.framework.restful.annotation.OperationType; +import neatlogic.framework.restful.annotation.Param; +import neatlogic.framework.restful.constvalue.OperationTypeEnum; +import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.util.Objects; + +@Service +@AuthAction(action = DATA_WAREHOUSE_MODIFY.class) +@OperationType(type = OperationTypeEnum.OPERATE) +@Transactional +public class ActiveDataSourceApi extends PrivateApiComponentBase { + + @Resource + private DataWarehouseDataSourceMapper reportDataSourceMapper; + + + @Resource + private DataSourceService reportDataSourceService; + + + @Override + public String getToken() { + return "datawarehouse/datasource/active"; + } + + @Override + public String getName() { + return "nmtad.activedatasourceapi.getname"; + } + + @Override + public String getConfig() { + return null; + } + + @Input({ + @Param(name = "id", type = ApiParamType.LONG, desc = "common.id", isRequired = true), + @Param(name = "isActive", type = ApiParamType.INTEGER, desc = "common.isactive", isRequired = true) + }) + @Description(desc = "nmtad.activedatasourceapi.getname") + @Override + public Object myDoService(JSONObject jsonObj) throws Exception { + Long id = jsonObj.getLong("id"); + DataSourceVo dataSourceVo = reportDataSourceMapper.getDataSourceById(id); + if (dataSourceVo == null) { + throw new DataSourceIsNotFoundException(id); + } + Integer isActive = jsonObj.getInteger("isActive"); + if (Objects.equals(dataSourceVo.getIsActive(), isActive)) { + return null; + } + dataSourceVo.setIsActive(isActive); + reportDataSourceMapper.updateReportDataSourceIsActive(dataSourceVo); + if (Objects.equals(dataSourceVo.getStatus(), Status.DOING.getValue())) { + dataSourceVo.setStatus(Status.ABORTED.getValue()); + dataSourceVo.setDataCount(null); + reportDataSourceMapper.updateReportDataSourceStatus(dataSourceVo); + } + reportDataSourceService.loadOrUnloadReportDataSourceJob(dataSourceVo); + return null; + } + +} -- Gitee