diff --git a/src/backend/turbo/biz-turbo/src/main/kotlin/com/tencent/devops/turbo/dao/mongotemplate/TbsDaySummaryDao.kt b/src/backend/turbo/biz-turbo/src/main/kotlin/com/tencent/devops/turbo/dao/mongotemplate/TbsDaySummaryDao.kt index a1747d726..615820ebf 100644 --- a/src/backend/turbo/biz-turbo/src/main/kotlin/com/tencent/devops/turbo/dao/mongotemplate/TbsDaySummaryDao.kt +++ b/src/backend/turbo/biz-turbo/src/main/kotlin/com/tencent/devops/turbo/dao/mongotemplate/TbsDaySummaryDao.kt @@ -77,6 +77,7 @@ class TbsDaySummaryDao @Autowired constructor( val criteria = Criteria.where("day").gte(startDate).lte(endDate) .and("user").`is`(null) + .and("total_time_with_cpu").gt(0) .and("engine_code").ne("disttask-ue4") .apply { if (filterPlanIdNin.isNotEmpty()) and("plan_id").nin(filterPlanIdNin) } .apply { if (filterProjectIdNin.isNotEmpty()) and("project_id").nin(filterProjectIdNin) } @@ -112,6 +113,7 @@ class TbsDaySummaryDao @Autowired constructor( logger.info("findByDayForUE startDate: $startDate, endDate: $endDate, filterPlanIdNin: $filterPlanIdNin") val criteria = Criteria.where("day").gte(startDate).lte(endDate) .and("user").ne(null) + .and("total_time_with_cpu").gt(0) .and("engine_code").`is`("disttask-ue4") .apply { if (filterPlanIdNin.isNotEmpty()) and("plan_id").nin(filterPlanIdNin) diff --git a/src/backend/turbo/biz-turbo/src/main/kotlin/com/tencent/devops/turbo/dao/repository/BaseDataRepository.kt b/src/backend/turbo/biz-turbo/src/main/kotlin/com/tencent/devops/turbo/dao/repository/BaseDataRepository.kt index 017efc303..982203992 100644 --- a/src/backend/turbo/biz-turbo/src/main/kotlin/com/tencent/devops/turbo/dao/repository/BaseDataRepository.kt +++ b/src/backend/turbo/biz-turbo/src/main/kotlin/com/tencent/devops/turbo/dao/repository/BaseDataRepository.kt @@ -11,4 +11,9 @@ interface BaseDataRepository : MongoRepository { * 根据参数标识代码查询 */ fun findFirstByParamCode(paramCode: String): BaseDataEntity? + + /** + * 根据参数标识代码list查询 + */ + fun findByParamCodeIn(paramCodeList: List): List } diff --git a/src/backend/turbo/biz-turbo/src/main/kotlin/com/tencent/devops/turbo/service/ProjectResourcesService.kt b/src/backend/turbo/biz-turbo/src/main/kotlin/com/tencent/devops/turbo/service/ProjectResourcesService.kt index 6f0781787..a269e87c2 100644 --- a/src/backend/turbo/biz-turbo/src/main/kotlin/com/tencent/devops/turbo/service/ProjectResourcesService.kt +++ b/src/backend/turbo/biz-turbo/src/main/kotlin/com/tencent/devops/turbo/service/ProjectResourcesService.kt @@ -6,7 +6,8 @@ import com.tencent.devops.common.api.exception.code.TURBO_PARAM_INVALID import com.tencent.devops.common.api.pojo.Page import com.tencent.devops.common.util.JsonUtil import com.tencent.devops.common.util.MathUtil -import com.tencent.devops.common.util.constants.BASE_EXCLUDED_PLAN_ID_LIST +import com.tencent.devops.common.util.constants.BASE_EXCLUDED_COMMON_PLAN_ID +import com.tencent.devops.common.util.constants.BASE_EXCLUDED_PLAN_ID_LIST_FOR_DEV_CLOUD import com.tencent.devops.common.util.constants.BASE_EXCLUDED_PROJECT_ID_LIST import com.tencent.devops.turbo.config.TodCostProperties import com.tencent.devops.turbo.dao.mongotemplate.TbsDaySummaryDao @@ -50,8 +51,9 @@ class ProjectResourcesService @Autowired constructor( val pageSizeNum = pageSize?.coerceAtMost(10000) ?: 100 // 获取需要过滤掉的方案id集合 - val baseDataEntity = baseDataRepository.findFirstByParamCode(BASE_EXCLUDED_PLAN_ID_LIST) - val filterPlanIds = baseDataEntity?.paramValue?.split(",")?.toSet() ?: emptySet() + val baseDataEntityList = baseDataRepository.findByParamCodeIn(listOf(BASE_EXCLUDED_PLAN_ID_LIST_FOR_DEV_CLOUD, + BASE_EXCLUDED_COMMON_PLAN_ID)) + val filterPlanIds = baseDataEntityList.flatMap { it.paramValue.split(",") }.toSet() ?: emptySet() // 获取需要过滤掉的项目id集合 val projectExcludedEntity = baseDataRepository.findFirstByParamCode(BASE_EXCLUDED_PROJECT_ID_LIST) @@ -120,7 +122,7 @@ class ProjectResourcesService @Autowired constructor( val end = endDate?.let { LocalDate.parse(it) } ?: today.withDayOfMonth(14) this.checkDatesInMonth(month, start, end) - val filterPlanIds = getFilterIds(BASE_EXCLUDED_PLAN_ID_LIST) + val filterPlanIds = getFilterIds(BASE_EXCLUDED_COMMON_PLAN_ID) val filterProjectIds = getFilterIds(BASE_EXCLUDED_PROJECT_ID_LIST) val properties = SpringContextHolder.getBean() diff --git a/src/backend/turbo/common-turbo/common-turbo-quartz/build.gradle.kts b/src/backend/turbo/common-turbo/common-turbo-quartz/build.gradle.kts index 143e60a09..cb30b1e89 100644 --- a/src/backend/turbo/common-turbo/common-turbo-quartz/build.gradle.kts +++ b/src/backend/turbo/common-turbo/common-turbo-quartz/build.gradle.kts @@ -1,7 +1,7 @@ dependencies { api("org.quartz-scheduler:quartz") api("org.quartz-scheduler:quartz-jobs") - api("com.novemberain:quartz-mongodb:2.2.0-rc2") + api("io.fluidsonic.mirror:quartz-mongodb:2.2.0-rc2") api("org.springframework.boot:spring-boot-starter") api("org.springframework:spring-context-support") api("org.springframework:spring-tx") diff --git a/src/backend/turbo/common-turbo/common-turbo-util/src/main/kotlin/com/tencent/devops/common/util/constants/TurboConstants.kt b/src/backend/turbo/common-turbo/common-turbo-util/src/main/kotlin/com/tencent/devops/common/util/constants/TurboConstants.kt index 77f7db81c..af6726a40 100644 --- a/src/backend/turbo/common-turbo/common-turbo-util/src/main/kotlin/com/tencent/devops/common/util/constants/TurboConstants.kt +++ b/src/backend/turbo/common-turbo/common-turbo-util/src/main/kotlin/com/tencent/devops/common/util/constants/TurboConstants.kt @@ -11,11 +11,17 @@ const val SYSTEM_ADMIN = "Turbo" const val NO_ADMIN_MEMBER_MESSAGE = "无权限,请先加入项目!" /** - * 统计数据需排除的plan id + * 统计数据需排除的plan id(DevCloud专用统计排除,服务计费不需要过滤掉) + * 微信和王者的机器资源是他们自己管理,DevCloud无需计费,咱们内部计费需要纳入统计 */ -const val BASE_EXCLUDED_PLAN_ID_LIST = "EXCLUDED_PLAN_ID_LIST" +const val BASE_EXCLUDED_PLAN_ID_LIST_FOR_DEV_CLOUD = "EXCLUDED_PLAN_ID_LIST" /** * 统计数据需排除的project id */ const val BASE_EXCLUDED_PROJECT_ID_LIST = "EXCLUDED_PROJECT_ID_LIST" + +/** + * 内部测试的方案,服务计费时需要过滤掉 + */ +const val BASE_EXCLUDED_COMMON_PLAN_ID = "EXCLUDED_COMMON_PLAN_ID_LIST"