You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by GitBox <gi...@apache.org> on 2022/11/28 16:34:45 UTC

[GitHub] [dolphinscheduler] insist777 opened a new pull request, #13031: [Feature][API] New restful API for workflow state

insist777 opened a new pull request, #13031:
URL: https://github.com/apache/dolphinscheduler/pull/13031

   workflow state Statistics
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [dolphinscheduler] insist777 commented on a diff in pull request #13031: [Feature][API] New restful API for workflow state

Posted by GitBox <gi...@apache.org>.
insist777 commented on code in PR #13031:
URL: https://github.com/apache/dolphinscheduler/pull/13031#discussion_r1035414642


##########
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/DateUtils.java:
##########
@@ -480,6 +480,21 @@ public static Date getLastDayOfMonth(Date date) {
         return cal.getTime();
     }
 
+    /**
+     * get a month ago
+     *
+     * @param date date
+     * @return get a month ago
+     */
+    public static Date getMonthAgo(Date date) {

Review Comment:
   done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [dolphinscheduler] insist777 commented on a diff in pull request #13031: [Feature][API] New restful API for workflow state

Posted by GitBox <gi...@apache.org>.
insist777 commented on code in PR #13031:
URL: https://github.com/apache/dolphinscheduler/pull/13031#discussion_r1036670738


##########
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ProcessInstanceMapper.java:
##########
@@ -287,4 +288,25 @@ IPage<ProcessInstance> queryProcessInstanceListV2Paging(Page<ProcessInstance> pa
                                                             @Param("state") Integer state,
                                                             @Param("host") String host);
 
+    /**
+     * Statistics process instance state v2
+     * <p>
+     * We only need project codes to determine whether the process instance belongs to the user or not.
+     *
+     * @param startTime    startTime
+     * @param endTime      endTime
+     * @param projectCode  projectCode
+     * @param workflowCode workflowCode
+     * @param model model

Review Comment:
   There are examples in StatisticsStateRequest.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #13031: [Feature][API] New restful API for workflow state

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #13031:
URL: https://github.com/apache/dolphinscheduler/pull/13031#issuecomment-1331513312

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=13031)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=BUG) [![C](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/C-16px.png 'C')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=BUG) [2 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=CODE_SMELL) [15 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=CODE_SMELL)
   
   [![3.8%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '3.8%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=13031&metric=new_coverage&view=list) [3.8% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=13031&metric=new_coverage&view=list)  
   [![2.2%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '2.2%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=13031&metric=new_duplicated_lines_density&view=list) [2.2% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=13031&metric=new_duplicated_lines_density&view=list)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #13031: [Feature][API] New restful API for workflow state

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #13031:
URL: https://github.com/apache/dolphinscheduler/pull/13031#issuecomment-1333153231

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=13031)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=BUG) [![C](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/C-16px.png 'C')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=BUG) [2 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=CODE_SMELL) [23 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=CODE_SMELL)
   
   [![12.5%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '12.5%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=13031&metric=new_coverage&view=list) [12.5% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=13031&metric=new_coverage&view=list)  
   [![1.7%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '1.7%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=13031&metric=new_duplicated_lines_density&view=list) [1.7% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=13031&metric=new_duplicated_lines_density&view=list)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [dolphinscheduler] zhongjiajie commented on pull request #13031: [Feature][API] New restful API for workflow state

Posted by GitBox <gi...@apache.org>.
zhongjiajie commented on PR #13031:
URL: https://github.com/apache/dolphinscheduler/pull/13031#issuecomment-1330008899

   BTW, I am not sure about that, but can we add some UT for these?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [dolphinscheduler] insist777 commented on a diff in pull request #13031: [Feature][API] New restful API for workflow state

Posted by GitBox <gi...@apache.org>.
insist777 commented on code in PR #13031:
URL: https://github.com/apache/dolphinscheduler/pull/13031#discussion_r1035413659


##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/StatisticsV2Controller.java:
##########
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.api.controller;
+
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ALL_WORKFLOW_COUNT_ERROR;
+
+import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
+import org.apache.dolphinscheduler.api.dto.project.StatisticsStateRequest;
+import org.apache.dolphinscheduler.api.exceptions.ApiException;
+import org.apache.dolphinscheduler.api.service.DataAnalysisService;
+import org.apache.dolphinscheduler.api.service.ProjectService;
+import org.apache.dolphinscheduler.api.utils.Result;
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.dao.entity.User;
+
+import java.util.Map;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestAttribute;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestController;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
+/**
+ * workflow instance controller
+ */
+@Tag(name = "STATISTICS_V2")
+@RestController
+@RequestMapping("/v2/statistics")
+public class StatisticsV2Controller extends BaseController {
+
+    @Autowired
+    private ProjectService projectService;
+
+    @Autowired
+    private DataAnalysisService dataAnalysisService;
+    /**
+     * query all workflow count
+     * @param loginUser login user
+     * @return workflow count
+     */
+    @Operation(summary = "queryAllWorkflowCount", description = "QUERY_ALL_WORKFLOW_COUNT")
+    @GetMapping(value = "/workflows/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_ALL_WORKFLOW_COUNT_ERROR)

Review Comment:
   done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [dolphinscheduler] insist777 commented on a diff in pull request #13031: [Feature][API] New restful API for workflow state

Posted by GitBox <gi...@apache.org>.
insist777 commented on code in PR #13031:
URL: https://github.com/apache/dolphinscheduler/pull/13031#discussion_r1035413842


##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProjectService.java:
##########
@@ -204,4 +205,27 @@ Result queryProjectWithAuthorizedLevelListPaging(Integer userId, User loginUser,
      */
     Result queryAllProjectListForDependent();
 
+    /**
+     * query all workflow count
+     * @param loginUser login user
+     * @return workflow count
+     */
+    Result queryAllWorkflowCounts(User loginUser);

Review Comment:
   done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [dolphinscheduler] zhongjiajie merged pull request #13031: [Feature][API] New restful API for workflow state

Posted by GitBox <gi...@apache.org>.
zhongjiajie merged PR #13031:
URL: https://github.com/apache/dolphinscheduler/pull/13031


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [dolphinscheduler] zhongjiajie commented on a diff in pull request #13031: [Feature][API] New restful API for workflow state

Posted by GitBox <gi...@apache.org>.
zhongjiajie commented on code in PR #13031:
URL: https://github.com/apache/dolphinscheduler/pull/13031#discussion_r1034237604


##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/project/StatisticsStateRequest.java:
##########
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.api.dto.project;
+
+import java.util.Date;
+
+import lombok.Data;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import io.swagger.v3.oas.annotations.media.Schema;
+
+@Data
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class StatisticsStateRequest {
+
+    @Schema(name = "isAll", example = "isAll")

Review Comment:
   same as start date or end date
   ```suggestion
       @Schema(name = "isAll", example = "true")
   ```



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/StatisticsV2Controller.java:
##########
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.api.controller;
+
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ALL_WORKFLOW_COUNT_ERROR;
+
+import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
+import org.apache.dolphinscheduler.api.dto.project.StatisticsStateRequest;
+import org.apache.dolphinscheduler.api.exceptions.ApiException;
+import org.apache.dolphinscheduler.api.service.DataAnalysisService;
+import org.apache.dolphinscheduler.api.service.ProjectService;
+import org.apache.dolphinscheduler.api.utils.Result;
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.dao.entity.User;
+
+import java.util.Map;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestAttribute;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestController;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
+/**
+ * workflow instance controller
+ */
+@Tag(name = "STATISTICS_V2")
+@RestController
+@RequestMapping("/v2/statistics")
+public class StatisticsV2Controller extends BaseController {
+
+    @Autowired
+    private ProjectService projectService;
+
+    @Autowired
+    private DataAnalysisService dataAnalysisService;
+    /**
+     * query all workflow count
+     * @param loginUser login user
+     * @return workflow count
+     */
+    @Operation(summary = "queryAllWorkflowCount", description = "QUERY_ALL_WORKFLOW_COUNT")
+    @GetMapping(value = "/workflows/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_ALL_WORKFLOW_COUNT_ERROR)

Review Comment:
   `QUERY_ALL_WORKFLOW_COUNT_ERROR` should we use different Exception in different entry point?



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/StatisticsV2Controller.java:
##########
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.api.controller;
+
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ALL_WORKFLOW_COUNT_ERROR;
+
+import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
+import org.apache.dolphinscheduler.api.dto.project.StatisticsStateRequest;
+import org.apache.dolphinscheduler.api.exceptions.ApiException;
+import org.apache.dolphinscheduler.api.service.DataAnalysisService;
+import org.apache.dolphinscheduler.api.service.ProjectService;
+import org.apache.dolphinscheduler.api.utils.Result;
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.dao.entity.User;
+
+import java.util.Map;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestAttribute;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestController;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
+/**
+ * workflow instance controller
+ */
+@Tag(name = "STATISTICS_V2")
+@RestController
+@RequestMapping("/v2/statistics")
+public class StatisticsV2Controller extends BaseController {
+
+    @Autowired
+    private ProjectService projectService;
+
+    @Autowired
+    private DataAnalysisService dataAnalysisService;
+    /**
+     * query all workflow count
+     * @param loginUser login user
+     * @return workflow count
+     */
+    @Operation(summary = "queryAllWorkflowCount", description = "QUERY_ALL_WORKFLOW_COUNT")
+    @GetMapping(value = "/workflows/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_ALL_WORKFLOW_COUNT_ERROR)

Review Comment:
   And I find out the Operation. summary is also the same, do you set they same for some reason?



##########
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/DateUtils.java:
##########
@@ -480,6 +480,21 @@ public static Date getLastDayOfMonth(Date date) {
         return cal.getTime();
     }
 
+    /**
+     * get a month ago
+     *
+     * @param date date
+     * @return get a month ago
+     */
+    public static Date getMonthAgo(Date date) {

Review Comment:
   can we reuse the function name `addMonths` in this util?



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/project/StatisticsStateRequest.java:
##########
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.api.dto.project;
+
+import java.util.Date;
+
+import lombok.Data;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import io.swagger.v3.oas.annotations.media.Schema;
+
+@Data
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class StatisticsStateRequest {
+
+    @Schema(name = "isAll", example = "isAll")
+    boolean isAll;
+
+    @Schema(name = "projectName", example = "PROJECT-NAME")
+    String projectName;
+
+    @Schema(name = "workflowName", example = "WORKFLOW-NAME")
+    String workflowName;
+
+    @Schema(name = "startDate", example = "START-TIME")

Review Comment:
   this example should use a date string instead of a pure string because this is an example of the parameter. Same as end date
   ```suggestion
       @Schema(name = "startDate", example = "2022-01-01 10:01:02")
   ```



##########
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProcessInstanceMapper.xml:
##########
@@ -308,6 +308,30 @@
         </if>
         order by instance.start_time desc,instance.id desc
     </select>
+    <select id="countInstanceStateV2" resultType="org.apache.dolphinscheduler.dao.entity.ExecuteStatusCount">

Review Comment:
   we should use `org.apache.dolphinscheduler.api.enums.ExecuteType` instead of `org.apache.dolphinscheduler.dao.entity.ExecuteStatusCount`, ExecuteStatusCount if for task status not for workflow 



##########
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProcessInstanceMapper.xml:
##########
@@ -308,6 +308,30 @@
         </if>
         order by instance.start_time desc,instance.id desc
     </select>
+    <select id="countInstanceStateV2" resultType="org.apache.dolphinscheduler.dao.entity.ExecuteStatusCount">
+        select t.state, count(0) as count
+        from t_ds_process_instance t
+        join t_ds_process_definition d on d.code=t.process_definition_code
+        join t_ds_project p on p.code=d.project_code
+        where 1 = 1
+        and t.is_sub_process = 0
+        <if test="projectIds != null and projectIds.size() != 0">
+            and p.id in
+            <foreach collection="projectIds" index="index" item="i" open="(" close=")" separator=",">
+                #{i}
+            </foreach>
+        </if>
+        <if test="startTime != null and endTime != null">
+            and t.start_time <![CDATA[ >= ]]> #{startTime} and t.start_time <![CDATA[ <= ]]> #{endTime}
+        </if>
+        <if test="model >= 1">
+           and p.name = #{projectName}
+        </if>
+        <if test="model >= 2">
+            and d.name = #{workflowName}

Review Comment:
   should we also support the workflow_code(process definition code) to query the stats?



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java:
##########
@@ -799,4 +809,85 @@ public Result queryAllProjectListForDependent() {
         return result;
     }
 
+    /**
+     * query all workflow count
+     *
+     * @param loginUser login user
+     * @return workflow count
+     */
+    @Override
+    public Result queryAllWorkflowCounts(User loginUser) {
+        Result result = new Result();
+        WorkflowCountResponse workflowCountResponse = new WorkflowCountResponse();
+        Set<Integer> projectIds = resourcePermissionCheckService
+                .userOwnedResourceIdsAcquisition(AuthorizationType.PROJECTS, loginUser.getId(), logger);
+        if (projectIds.isEmpty()) {
+            result.setData(workflowCountResponse);
+            putMsg(result, Status.SUCCESS);
+            return result;
+        }
+        List<Project> projects = projectMapper.selectBatchIds(projectIds);
+
+        List<Long> projectCodes = projects.stream().map(project -> project.getCode()).collect(Collectors.toList());
+
+        workflowCountResponse.setWorkflowCounts(projectMapper.queryAllWorkflowCounts(projectCodes));
+
+        putMsg(workflowCountResponse, Status.SUCCESS);
+        return workflowCountResponse;
+    }
+
+    /**
+     * query all workflow States count
+     * @param loginUser login user
+     * @param statisticsStateRequest statisticsStateRequest
+     * @return workflow States count
+     */
+    @Override
+    public Map<String, Object> countWorkflowStates(User loginUser,
+                                                   StatisticsStateRequest statisticsStateRequest) {
+        Map<String, Object> result = new HashMap<>();
+        Set<Integer> projectIds = resourcePermissionCheckService
+                .userOwnedResourceIdsAcquisition(AuthorizationType.PROJECTS, loginUser.getId(), logger);
+        if (projectIds.isEmpty()) {
+            putMsg(result, Status.SUCCESS);
+            return result;
+        }
+        String projectName = statisticsStateRequest.getProjectName();
+        String workflowName = statisticsStateRequest.getWorkflowName();
+        Date date = new Date();
+        Date startTime = statisticsStateRequest.getStartTime() == null ? DateUtils.getMonthAgo(date)
+                : statisticsStateRequest.getStartTime();
+        Date endTime = statisticsStateRequest.getEndTime() == null ? date : statisticsStateRequest.getEndTime();
+        Integer model = Constants.QUERY_ALL_ON_SYSTEM;
+        if (!StringUtils.isBlank(projectName)) {
+            model = Constants.QUERY_ALL_ON_PROJECT;
+        }
+        if (!StringUtils.isBlank(workflowName)) {
+            model = Constants.QUERY_ALL_ON_WORKFLOW;
+        }
+        List<ExecuteStatusCount> executeStatusCounts = processInstanceMapper.countInstanceStateV2(
+                startTime, endTime, projectName, workflowName, model, projectIds);
+        TaskCountDto taskCountResult = new TaskCountDto(executeStatusCounts);
+        result.put(Constants.DATA_LIST, taskCountResult);
+        putMsg(result, Status.SUCCESS);
+        return result;
+    }
+
+    @Override
+    public Map<String, Object> countOneWorkflowStates(User loginUser, String workflowName) {
+        Map<String, Object> result = new HashMap<>();
+        Project project = projectMapper.queryByName(workflowName);
+        boolean hasProjectAndWritePerm = hasProjectAndWritePerm(loginUser, project, result);
+        if (!hasProjectAndWritePerm) {
+            return result;
+        }
+        List<ExecuteStatusCount> executeStatusCounts = processInstanceMapper.countInstanceStateV2(
+                null, null, null, workflowName, Constants.QUERY_ALL_ON_WORKFLOW, null);
+        if (executeStatusCounts != null) {
+            TaskCountDto taskCountResult = new TaskCountDto(executeStatusCounts);

Review Comment:
   I think we should not use taskcout dto in workflow stats. but it is odd that the exists function `countProcessInstanceStateByProject` also use this function. do you know why they use them ?



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProjectService.java:
##########
@@ -204,4 +205,27 @@ Result queryProjectWithAuthorizedLevelListPaging(Integer userId, User loginUser,
      */
     Result queryAllProjectListForDependent();
 
+    /**
+     * query all workflow count
+     * @param loginUser login user
+     * @return workflow count
+     */
+    Result queryAllWorkflowCounts(User loginUser);

Review Comment:
   A question here, should we make three new interface return the same type? like a more general type about statistics data type for `List[Map<String, Long>]`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #13031: [Feature][API] New restful API for workflow state

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #13031:
URL: https://github.com/apache/dolphinscheduler/pull/13031#issuecomment-1333154888

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=13031)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=BUG) [![C](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/C-16px.png 'C')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=BUG) [2 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=CODE_SMELL) [23 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=CODE_SMELL)
   
   [![12.5%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '12.5%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=13031&metric=new_coverage&view=list) [12.5% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=13031&metric=new_coverage&view=list)  
   [![1.7%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '1.7%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=13031&metric=new_duplicated_lines_density&view=list) [1.7% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=13031&metric=new_duplicated_lines_density&view=list)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [dolphinscheduler] zhongjiajie commented on a diff in pull request #13031: [Feature][API] New restful API for workflow state

Posted by GitBox <gi...@apache.org>.
zhongjiajie commented on code in PR #13031:
URL: https://github.com/apache/dolphinscheduler/pull/13031#discussion_r1036634931


##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/StatisticsV2Controller.java:
##########
@@ -0,0 +1,209 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.api.controller;
+
+import static org.apache.dolphinscheduler.api.enums.Status.COUNT_PROCESS_DEFINITION_USER_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ALL_WORKFLOW_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ONE_TASK_STATES_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ONE_WORKFLOW_STATE_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_TASK_STATES_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_WORKFLOW_STATES_COUNT_ERROR;
+
+import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
+import org.apache.dolphinscheduler.api.dto.project.StatisticsStateRequest;
+import org.apache.dolphinscheduler.api.exceptions.ApiException;
+import org.apache.dolphinscheduler.api.service.DataAnalysisService;
+import org.apache.dolphinscheduler.api.utils.Result;
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.dao.entity.User;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.Map;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestAttribute;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestController;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
+/**
+ * StatisticsV2 controller
+ */
+@Tag(name = "STATISTICS_V2")
+@RestController
+@RequestMapping("/v2/statistics")
+public class StatisticsV2Controller extends BaseController {
+
+    @Autowired
+    private DataAnalysisService dataAnalysisService;
+
+    /**
+     * query all workflow count
+     * @param loginUser login user
+     * @return workflow count
+     */
+    @Operation(summary = "queryAllWorkflowCount", description = "QUERY_ALL_WORKFLOW_COUNT")
+    @GetMapping(value = "/workflows/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_ALL_WORKFLOW_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryWorkflowInstanceCounts(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser) {
+        Map<String, Object> result = dataAnalysisService.queryAllWorkflowCounts(loginUser);
+        return returnDataList(result);
+    }
+
+    /**
+     * query all workflow States count
+     * @param loginUser login user
+     * @param statisticsStateRequest statisticsStateRequest
+     * @return workflow States count
+     */
+    @Operation(summary = "queryAllWorkflowStatesCount", description = "QUERY_ALL_WORKFLOW_STATES_COUNT")
+    @GetMapping(value = "/workflows/states/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_WORKFLOW_STATES_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryWorkflowStatesCounts(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                            @RequestBody(required = false) StatisticsStateRequest statisticsStateRequest) {
+        Map<String, Object> result =
+                dataAnalysisService.countWorkflowStates(loginUser, statisticsStateRequest);
+        return returnDataList(result);
+    }
+
+    /**
+     * query one workflow States count

Review Comment:
   ```suggestion
        * query one workflow states count
   ```



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/StatisticsV2Controller.java:
##########
@@ -0,0 +1,209 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.api.controller;
+
+import static org.apache.dolphinscheduler.api.enums.Status.COUNT_PROCESS_DEFINITION_USER_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ALL_WORKFLOW_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ONE_TASK_STATES_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ONE_WORKFLOW_STATE_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_TASK_STATES_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_WORKFLOW_STATES_COUNT_ERROR;
+
+import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
+import org.apache.dolphinscheduler.api.dto.project.StatisticsStateRequest;
+import org.apache.dolphinscheduler.api.exceptions.ApiException;
+import org.apache.dolphinscheduler.api.service.DataAnalysisService;
+import org.apache.dolphinscheduler.api.utils.Result;
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.dao.entity.User;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.Map;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestAttribute;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestController;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
+/**
+ * StatisticsV2 controller
+ */
+@Tag(name = "STATISTICS_V2")
+@RestController
+@RequestMapping("/v2/statistics")
+public class StatisticsV2Controller extends BaseController {
+
+    @Autowired
+    private DataAnalysisService dataAnalysisService;
+
+    /**
+     * query all workflow count
+     * @param loginUser login user
+     * @return workflow count
+     */
+    @Operation(summary = "queryAllWorkflowCount", description = "QUERY_ALL_WORKFLOW_COUNT")
+    @GetMapping(value = "/workflows/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_ALL_WORKFLOW_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryWorkflowInstanceCounts(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser) {
+        Map<String, Object> result = dataAnalysisService.queryAllWorkflowCounts(loginUser);
+        return returnDataList(result);
+    }
+
+    /**
+     * query all workflow States count

Review Comment:
   ```suggestion
        * query all workflow states count
   ```



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/StatisticsV2Controller.java:
##########
@@ -0,0 +1,209 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.api.controller;
+
+import static org.apache.dolphinscheduler.api.enums.Status.COUNT_PROCESS_DEFINITION_USER_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ALL_WORKFLOW_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ONE_TASK_STATES_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ONE_WORKFLOW_STATE_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_TASK_STATES_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_WORKFLOW_STATES_COUNT_ERROR;
+
+import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
+import org.apache.dolphinscheduler.api.dto.project.StatisticsStateRequest;
+import org.apache.dolphinscheduler.api.exceptions.ApiException;
+import org.apache.dolphinscheduler.api.service.DataAnalysisService;
+import org.apache.dolphinscheduler.api.utils.Result;
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.dao.entity.User;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.Map;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestAttribute;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestController;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
+/**
+ * StatisticsV2 controller
+ */
+@Tag(name = "STATISTICS_V2")
+@RestController
+@RequestMapping("/v2/statistics")
+public class StatisticsV2Controller extends BaseController {
+
+    @Autowired
+    private DataAnalysisService dataAnalysisService;
+
+    /**
+     * query all workflow count
+     * @param loginUser login user
+     * @return workflow count
+     */
+    @Operation(summary = "queryAllWorkflowCount", description = "QUERY_ALL_WORKFLOW_COUNT")
+    @GetMapping(value = "/workflows/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_ALL_WORKFLOW_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryWorkflowInstanceCounts(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser) {
+        Map<String, Object> result = dataAnalysisService.queryAllWorkflowCounts(loginUser);
+        return returnDataList(result);
+    }
+
+    /**
+     * query all workflow States count
+     * @param loginUser login user
+     * @param statisticsStateRequest statisticsStateRequest
+     * @return workflow States count
+     */
+    @Operation(summary = "queryAllWorkflowStatesCount", description = "QUERY_ALL_WORKFLOW_STATES_COUNT")
+    @GetMapping(value = "/workflows/states/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_WORKFLOW_STATES_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryWorkflowStatesCounts(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                            @RequestBody(required = false) StatisticsStateRequest statisticsStateRequest) {
+        Map<String, Object> result =
+                dataAnalysisService.countWorkflowStates(loginUser, statisticsStateRequest);
+        return returnDataList(result);
+    }
+
+    /**
+     * query one workflow States count
+     * @param loginUser login user
+     * @param workflowCode workflowCode
+     * @return workflow States count
+     */
+    @Operation(summary = "queryOneWorkflowStatesCount", description = "QUERY_One_WORKFLOW_STATES_COUNT")
+    @GetMapping(value = "/{workflowCode}/states/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_ONE_WORKFLOW_STATE_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryOneWorkflowStates(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                         @PathVariable("workflowCode") Long workflowCode) {
+        Map<String, Object> result =
+                dataAnalysisService.countOneWorkflowStates(loginUser, workflowCode);
+        return returnDataList(result);
+    }
+
+    /**
+     * query all task States count
+     * @param loginUser login user
+     * @param statisticsStateRequest statisticsStateRequest
+     * @return tasks States count

Review Comment:
   ```suggestion
        * @return tasks states count
   ```



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/StatisticsV2Controller.java:
##########
@@ -0,0 +1,209 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.api.controller;
+
+import static org.apache.dolphinscheduler.api.enums.Status.COUNT_PROCESS_DEFINITION_USER_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ALL_WORKFLOW_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ONE_TASK_STATES_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ONE_WORKFLOW_STATE_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_TASK_STATES_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_WORKFLOW_STATES_COUNT_ERROR;
+
+import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
+import org.apache.dolphinscheduler.api.dto.project.StatisticsStateRequest;
+import org.apache.dolphinscheduler.api.exceptions.ApiException;
+import org.apache.dolphinscheduler.api.service.DataAnalysisService;
+import org.apache.dolphinscheduler.api.utils.Result;
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.dao.entity.User;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.Map;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestAttribute;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestController;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
+/**
+ * StatisticsV2 controller
+ */
+@Tag(name = "STATISTICS_V2")
+@RestController
+@RequestMapping("/v2/statistics")
+public class StatisticsV2Controller extends BaseController {
+
+    @Autowired
+    private DataAnalysisService dataAnalysisService;
+
+    /**
+     * query all workflow count
+     * @param loginUser login user
+     * @return workflow count
+     */
+    @Operation(summary = "queryAllWorkflowCount", description = "QUERY_ALL_WORKFLOW_COUNT")
+    @GetMapping(value = "/workflows/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_ALL_WORKFLOW_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryWorkflowInstanceCounts(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser) {
+        Map<String, Object> result = dataAnalysisService.queryAllWorkflowCounts(loginUser);
+        return returnDataList(result);
+    }
+
+    /**
+     * query all workflow States count
+     * @param loginUser login user
+     * @param statisticsStateRequest statisticsStateRequest
+     * @return workflow States count
+     */
+    @Operation(summary = "queryAllWorkflowStatesCount", description = "QUERY_ALL_WORKFLOW_STATES_COUNT")
+    @GetMapping(value = "/workflows/states/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_WORKFLOW_STATES_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryWorkflowStatesCounts(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                            @RequestBody(required = false) StatisticsStateRequest statisticsStateRequest) {
+        Map<String, Object> result =
+                dataAnalysisService.countWorkflowStates(loginUser, statisticsStateRequest);
+        return returnDataList(result);
+    }
+
+    /**
+     * query one workflow States count
+     * @param loginUser login user
+     * @param workflowCode workflowCode
+     * @return workflow States count
+     */
+    @Operation(summary = "queryOneWorkflowStatesCount", description = "QUERY_One_WORKFLOW_STATES_COUNT")
+    @GetMapping(value = "/{workflowCode}/states/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_ONE_WORKFLOW_STATE_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryOneWorkflowStates(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                         @PathVariable("workflowCode") Long workflowCode) {
+        Map<String, Object> result =
+                dataAnalysisService.countOneWorkflowStates(loginUser, workflowCode);
+        return returnDataList(result);
+    }
+
+    /**
+     * query all task States count
+     * @param loginUser login user
+     * @param statisticsStateRequest statisticsStateRequest
+     * @return tasks States count
+     */
+    @Operation(summary = "queryAllTaskStatesCount", description = "QUERY_ALL_TASK_STATES_COUNT")
+    @GetMapping(value = "/tasks/states/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_TASK_STATES_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryTaskStatesCounts(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                        @RequestBody(required = false) StatisticsStateRequest statisticsStateRequest) {
+        Map<String, Object> result =
+                dataAnalysisService.countTaskStates(loginUser, statisticsStateRequest);
+        return returnDataList(result);
+    }
+
+    /**
+     * query one task States count
+     * @param loginUser login user
+     * @param taskCode taskCode
+     * @return tasks States count
+     */
+    @Operation(summary = "queryOneTaskStatesCount", description = "QUERY_ONE_TASK_STATES_COUNT")
+    @GetMapping(value = "/tasks/{taskCode}/states/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_ONE_TASK_STATES_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryOneTaskStatesCounts(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                           @PathVariable("taskCode") Long taskCode) {
+        Map<String, Object> result =
+                dataAnalysisService.countOneTaskStates(loginUser, taskCode);
+        return returnDataList(result);
+    }
+
+    /**
+     * statistics the process definition quantities of certain person

Review Comment:
   ```suggestion
        * statistics the workflow quantities of certain user
   ```



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/StatisticsV2Controller.java:
##########
@@ -0,0 +1,209 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.api.controller;
+
+import static org.apache.dolphinscheduler.api.enums.Status.COUNT_PROCESS_DEFINITION_USER_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ALL_WORKFLOW_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ONE_TASK_STATES_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ONE_WORKFLOW_STATE_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_TASK_STATES_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_WORKFLOW_STATES_COUNT_ERROR;
+
+import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
+import org.apache.dolphinscheduler.api.dto.project.StatisticsStateRequest;
+import org.apache.dolphinscheduler.api.exceptions.ApiException;
+import org.apache.dolphinscheduler.api.service.DataAnalysisService;
+import org.apache.dolphinscheduler.api.utils.Result;
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.dao.entity.User;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.Map;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestAttribute;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestController;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
+/**
+ * StatisticsV2 controller
+ */
+@Tag(name = "STATISTICS_V2")
+@RestController
+@RequestMapping("/v2/statistics")
+public class StatisticsV2Controller extends BaseController {
+
+    @Autowired
+    private DataAnalysisService dataAnalysisService;
+
+    /**
+     * query all workflow count
+     * @param loginUser login user
+     * @return workflow count
+     */
+    @Operation(summary = "queryAllWorkflowCount", description = "QUERY_ALL_WORKFLOW_COUNT")
+    @GetMapping(value = "/workflows/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_ALL_WORKFLOW_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryWorkflowInstanceCounts(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser) {
+        Map<String, Object> result = dataAnalysisService.queryAllWorkflowCounts(loginUser);
+        return returnDataList(result);
+    }
+
+    /**
+     * query all workflow States count
+     * @param loginUser login user
+     * @param statisticsStateRequest statisticsStateRequest
+     * @return workflow States count
+     */
+    @Operation(summary = "queryAllWorkflowStatesCount", description = "QUERY_ALL_WORKFLOW_STATES_COUNT")
+    @GetMapping(value = "/workflows/states/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_WORKFLOW_STATES_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryWorkflowStatesCounts(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                            @RequestBody(required = false) StatisticsStateRequest statisticsStateRequest) {
+        Map<String, Object> result =
+                dataAnalysisService.countWorkflowStates(loginUser, statisticsStateRequest);
+        return returnDataList(result);
+    }
+
+    /**
+     * query one workflow States count
+     * @param loginUser login user
+     * @param workflowCode workflowCode
+     * @return workflow States count
+     */
+    @Operation(summary = "queryOneWorkflowStatesCount", description = "QUERY_One_WORKFLOW_STATES_COUNT")
+    @GetMapping(value = "/{workflowCode}/states/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_ONE_WORKFLOW_STATE_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryOneWorkflowStates(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                         @PathVariable("workflowCode") Long workflowCode) {
+        Map<String, Object> result =
+                dataAnalysisService.countOneWorkflowStates(loginUser, workflowCode);
+        return returnDataList(result);
+    }
+
+    /**
+     * query all task States count
+     * @param loginUser login user
+     * @param statisticsStateRequest statisticsStateRequest
+     * @return tasks States count
+     */
+    @Operation(summary = "queryAllTaskStatesCount", description = "QUERY_ALL_TASK_STATES_COUNT")
+    @GetMapping(value = "/tasks/states/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_TASK_STATES_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryTaskStatesCounts(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                        @RequestBody(required = false) StatisticsStateRequest statisticsStateRequest) {
+        Map<String, Object> result =
+                dataAnalysisService.countTaskStates(loginUser, statisticsStateRequest);
+        return returnDataList(result);
+    }
+
+    /**
+     * query one task States count
+     * @param loginUser login user
+     * @param taskCode taskCode
+     * @return tasks States count
+     */
+    @Operation(summary = "queryOneTaskStatesCount", description = "QUERY_ONE_TASK_STATES_COUNT")
+    @GetMapping(value = "/tasks/{taskCode}/states/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_ONE_TASK_STATES_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryOneTaskStatesCounts(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                           @PathVariable("taskCode") Long taskCode) {
+        Map<String, Object> result =
+                dataAnalysisService.countOneTaskStates(loginUser, taskCode);
+        return returnDataList(result);
+    }
+
+    /**
+     * statistics the process definition quantities of certain person
+     *
+     * @param loginUser login user
+     * @param statisticsStateRequest statisticsStateRequest
+     * @return definition count in project code
+     */
+    @Operation(summary = "countDefinitionV2ByUserId", description = "COUNT_PROCESS_DEFINITION_V2_BY_USERID_NOTES")
+    @GetMapping(value = "/workflows/users/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(COUNT_PROCESS_DEFINITION_USER_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result countDefinitionByUser(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                        @RequestBody(required = false) StatisticsStateRequest statisticsStateRequest) {
+        String projectName = statisticsStateRequest.getProjectName();
+        Long projectCode = statisticsStateRequest.getProjectCode();
+        if (null == projectCode && !StringUtils.isBlank(projectName)) {
+            projectCode = dataAnalysisService.getProjectCodeByName(projectName);
+        }
+        Map<String, Object> result = dataAnalysisService.countDefinitionByUserV2(loginUser, projectCode, null, null);
+        return returnDataList(result);
+    }
+
+    /**
+     * statistics the process definition quantities of certain userId
+     *
+     * @param loginUser login user
+     * @param userId userId
+     * @return definition count in project code
+     */
+    @Operation(summary = "countDefinitionV2ByUser", description = "COUNT_PROCESS_DEFINITION_V2_BY_USER_NOTES")
+    @GetMapping(value = "/workflows/users/{userId}/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(COUNT_PROCESS_DEFINITION_USER_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result countDefinitionByUserId(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                          @PathVariable("userId") Integer userId) {
+        Map<String, Object> result = dataAnalysisService.countDefinitionByUserV2(loginUser, null, userId, null);
+        return returnDataList(result);
+    }
+    /**
+    * statistics the process definition quantities of certain userId filter releaseState
+    *
+    * @param loginUser login user
+    * @param userId userId
+    * @param releaseState releaseState
+    * @return definition count in project code

Review Comment:
   ```suggestion
       * @return workflow count in project code
   ```



##########
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ProcessInstanceMapper.java:
##########
@@ -287,4 +288,25 @@ IPage<ProcessInstance> queryProcessInstanceListV2Paging(Page<ProcessInstance> pa
                                                             @Param("state") Integer state,
                                                             @Param("host") String host);
 
+    /**
+     * Statistics process instance state v2
+     * <p>
+     * We only need project codes to determine whether the process instance belongs to the user or not.
+     *
+     * @param startTime    startTime
+     * @param endTime      endTime
+     * @param projectCode  projectCode
+     * @param workflowCode workflowCode
+     * @param model model

Review Comment:
   can we list the model value, make users know the meaning here? same as other interface using model



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataAnalysisServiceImpl.java:
##########
@@ -353,4 +359,250 @@ public List<ExecuteStatusCount> countTaskInstanceAllStatesByProjectCodes(Date st
 
         return startTimeStates.orElse(null);
     }
+    /**
+     * query all workflow count
+     *
+     * @param loginUser login user
+     * @return workflow count
+     */
+    @Override
+    public Map<String, Object> queryAllWorkflowCounts(User loginUser) {
+        Map<String, Object> result = new HashMap<>();
+        int count = 0;
+        Set<Integer> projectIds = resourcePermissionCheckService
+                .userOwnedResourceIdsAcquisition(AuthorizationType.PROJECTS, loginUser.getId(), logger);
+        if (!projectIds.isEmpty()) {
+            List<Project> projects = projectMapper.selectBatchIds(projectIds);
+            List<Long> projectCodes = projects.stream().map(project -> project.getCode()).collect(Collectors.toList());
+            count = projectMapper.queryAllWorkflowCounts(projectCodes);
+        }
+        result.put("data", "AllWorkflowCounts = " + count);
+        putMsg(result, Status.SUCCESS);
+        return result;
+    }
+
+    /**
+     * query all workflow States count
+     * @param loginUser login user
+     * @param statisticsStateRequest statisticsStateRequest
+     * @return workflow States count
+     */
+    @Override
+    public Map<String, Object> countWorkflowStates(User loginUser,
+                                                   StatisticsStateRequest statisticsStateRequest) {
+        Map<String, Object> result = new HashMap<>();
+        Set<Integer> projectIds = resourcePermissionCheckService
+                .userOwnedResourceIdsAcquisition(AuthorizationType.PROJECTS, loginUser.getId(), logger);
+        if (projectIds.isEmpty()) {
+            putMsg(result, Status.SUCCESS);
+            return result;
+        }
+
+        String projectName = statisticsStateRequest.getProjectName();
+        String workflowName = statisticsStateRequest.getWorkflowName();
+        Long projectCode = statisticsStateRequest.getProjectCode();
+        Long workflowCode = statisticsStateRequest.getWorkflowCode();
+        Integer model = Constants.QUERY_ALL_ON_SYSTEM;
+
+        if (!StringUtils.isBlank(projectName) || null != projectCode) {
+            model = Constants.QUERY_ALL_ON_PROJECT;
+        }
+        if (!StringUtils.isBlank(workflowName) || null != workflowCode) {
+            model = Constants.QUERY_ALL_ON_WORKFLOW;
+        }
+        try {
+            if (null == workflowCode || null == projectCode) {
+                projectCode = projectMapper.queryByName(projectName).getCode();
+                workflowCode = processDefinitionMapper.queryByDefineName(projectCode, workflowName).getCode();
+            }
+        } catch (Exception e) {
+
+        }
+
+        Date date = new Date();
+        Date startTime = statisticsStateRequest.getStartTime() == null ? DateUtils.addMonths(date, -1)
+                : statisticsStateRequest.getStartTime();
+        Date endTime = statisticsStateRequest.getEndTime() == null ? date : statisticsStateRequest.getEndTime();
+
+        List<ExecuteStatusCount> executeStatusCounts = processInstanceMapper.countInstanceStateV2(
+                startTime, endTime, projectCode, workflowCode, model, projectIds);
+        TaskCountDto taskCountResult = new TaskCountDto(executeStatusCounts);
+        result.put(Constants.DATA_LIST, taskCountResult);
+        putMsg(result, Status.SUCCESS);
+        return result;
+    }
+
+    @Override
+    public Map<String, Object> countOneWorkflowStates(User loginUser, Long workflowCode) {
+        Map<String, Object> result = new HashMap<>();
+        Project project = projectMapper.queryByCode(workflowCode);
+        boolean hasProjectAndWritePerm = projectService.hasProjectAndWritePerm(loginUser, project, result);
+        if (!hasProjectAndWritePerm) {
+            return result;
+        }
+        List<ExecuteStatusCount> executeStatusCounts = processInstanceMapper.countInstanceStateV2(
+                null, null, null, workflowCode, Constants.QUERY_ALL_ON_WORKFLOW, null);
+        if (executeStatusCounts != null) {
+            TaskCountDto taskCountResult = new TaskCountDto(executeStatusCounts);
+            result.put(Constants.DATA_LIST, taskCountResult);
+            putMsg(result, Status.SUCCESS);
+        }
+        return result;
+    }
+
+    @Override
+    public Map<String, Object> countTaskStates(User loginUser, StatisticsStateRequest statisticsStateRequest) {
+        Map<String, Object> result = new HashMap<>();
+        Set<Integer> projectIds = resourcePermissionCheckService
+                .userOwnedResourceIdsAcquisition(AuthorizationType.PROJECTS, loginUser.getId(), logger);
+        if (projectIds.isEmpty()) {
+            putMsg(result, Status.SUCCESS);
+            return result;
+        }
+        String projectName = statisticsStateRequest.getProjectName();
+        String workflowName = statisticsStateRequest.getWorkflowName();
+        String taskName = statisticsStateRequest.getTaskName();
+        Long projectCode = statisticsStateRequest.getProjectCode();
+        Long workflowCode = statisticsStateRequest.getWorkflowCode();
+        Long taskCode = statisticsStateRequest.getTaskCode();
+        Integer model = Constants.QUERY_ALL_ON_SYSTEM;
+
+        if (!StringUtils.isBlank(projectName) || null != projectCode) {
+            model = Constants.QUERY_ALL_ON_PROJECT;
+        }
+        if (!StringUtils.isBlank(workflowName) || null != workflowCode) {
+            model = Constants.QUERY_ALL_ON_WORKFLOW;
+        }
+        if (!StringUtils.isBlank(taskName) || null != taskCode) {
+            model = Constants.QUERY_ALL_ON_TASK;
+        }
+
+        try {
+            if (null == taskCode || null == workflowCode || null == projectCode) {
+                projectCode = projectMapper.queryByName(projectName).getCode();
+                workflowCode = processDefinitionMapper.queryByDefineName(projectCode, workflowName).getCode();
+                taskCode = relationMapper.queryTaskCodeByTaskName(workflowCode, taskName);
+            }
+        } catch (Exception e) {
+
+        }

Review Comment:
   if we do not handle the exception, we should not catch them



##########
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProcessInstanceMapper.xml:
##########
@@ -308,6 +308,30 @@
         </if>
         order by instance.start_time desc,instance.id desc
     </select>
+    <select id="countInstanceStateV2" resultType="org.apache.dolphinscheduler.dao.entity.ExecuteStatusCount">

Review Comment:
   resolve



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/StatisticsV2Controller.java:
##########
@@ -0,0 +1,209 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.api.controller;
+
+import static org.apache.dolphinscheduler.api.enums.Status.COUNT_PROCESS_DEFINITION_USER_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ALL_WORKFLOW_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ONE_TASK_STATES_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ONE_WORKFLOW_STATE_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_TASK_STATES_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_WORKFLOW_STATES_COUNT_ERROR;
+
+import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
+import org.apache.dolphinscheduler.api.dto.project.StatisticsStateRequest;
+import org.apache.dolphinscheduler.api.exceptions.ApiException;
+import org.apache.dolphinscheduler.api.service.DataAnalysisService;
+import org.apache.dolphinscheduler.api.utils.Result;
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.dao.entity.User;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.Map;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestAttribute;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestController;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
+/**
+ * StatisticsV2 controller
+ */
+@Tag(name = "STATISTICS_V2")
+@RestController
+@RequestMapping("/v2/statistics")
+public class StatisticsV2Controller extends BaseController {
+
+    @Autowired
+    private DataAnalysisService dataAnalysisService;
+
+    /**
+     * query all workflow count
+     * @param loginUser login user
+     * @return workflow count
+     */
+    @Operation(summary = "queryAllWorkflowCount", description = "QUERY_ALL_WORKFLOW_COUNT")
+    @GetMapping(value = "/workflows/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_ALL_WORKFLOW_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryWorkflowInstanceCounts(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser) {
+        Map<String, Object> result = dataAnalysisService.queryAllWorkflowCounts(loginUser);
+        return returnDataList(result);
+    }
+
+    /**
+     * query all workflow States count
+     * @param loginUser login user
+     * @param statisticsStateRequest statisticsStateRequest
+     * @return workflow States count

Review Comment:
   ```suggestion
        * @return workflow states count
   ```



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/StatisticsV2Controller.java:
##########
@@ -0,0 +1,209 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.api.controller;
+
+import static org.apache.dolphinscheduler.api.enums.Status.COUNT_PROCESS_DEFINITION_USER_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ALL_WORKFLOW_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ONE_TASK_STATES_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ONE_WORKFLOW_STATE_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_TASK_STATES_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_WORKFLOW_STATES_COUNT_ERROR;
+
+import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
+import org.apache.dolphinscheduler.api.dto.project.StatisticsStateRequest;
+import org.apache.dolphinscheduler.api.exceptions.ApiException;
+import org.apache.dolphinscheduler.api.service.DataAnalysisService;
+import org.apache.dolphinscheduler.api.utils.Result;
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.dao.entity.User;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.Map;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestAttribute;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestController;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
+/**
+ * StatisticsV2 controller
+ */
+@Tag(name = "STATISTICS_V2")
+@RestController
+@RequestMapping("/v2/statistics")
+public class StatisticsV2Controller extends BaseController {
+
+    @Autowired
+    private DataAnalysisService dataAnalysisService;
+
+    /**
+     * query all workflow count
+     * @param loginUser login user
+     * @return workflow count
+     */
+    @Operation(summary = "queryAllWorkflowCount", description = "QUERY_ALL_WORKFLOW_COUNT")
+    @GetMapping(value = "/workflows/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_ALL_WORKFLOW_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryWorkflowInstanceCounts(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser) {
+        Map<String, Object> result = dataAnalysisService.queryAllWorkflowCounts(loginUser);
+        return returnDataList(result);
+    }
+
+    /**
+     * query all workflow States count
+     * @param loginUser login user
+     * @param statisticsStateRequest statisticsStateRequest
+     * @return workflow States count
+     */
+    @Operation(summary = "queryAllWorkflowStatesCount", description = "QUERY_ALL_WORKFLOW_STATES_COUNT")
+    @GetMapping(value = "/workflows/states/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_WORKFLOW_STATES_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryWorkflowStatesCounts(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                            @RequestBody(required = false) StatisticsStateRequest statisticsStateRequest) {
+        Map<String, Object> result =
+                dataAnalysisService.countWorkflowStates(loginUser, statisticsStateRequest);
+        return returnDataList(result);
+    }
+
+    /**
+     * query one workflow States count
+     * @param loginUser login user
+     * @param workflowCode workflowCode
+     * @return workflow States count

Review Comment:
   ```suggestion
        * @return workflow states count
   ```



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/StatisticsV2Controller.java:
##########
@@ -0,0 +1,209 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.api.controller;
+
+import static org.apache.dolphinscheduler.api.enums.Status.COUNT_PROCESS_DEFINITION_USER_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ALL_WORKFLOW_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ONE_TASK_STATES_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ONE_WORKFLOW_STATE_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_TASK_STATES_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_WORKFLOW_STATES_COUNT_ERROR;
+
+import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
+import org.apache.dolphinscheduler.api.dto.project.StatisticsStateRequest;
+import org.apache.dolphinscheduler.api.exceptions.ApiException;
+import org.apache.dolphinscheduler.api.service.DataAnalysisService;
+import org.apache.dolphinscheduler.api.utils.Result;
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.dao.entity.User;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.Map;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestAttribute;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestController;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
+/**
+ * StatisticsV2 controller
+ */
+@Tag(name = "STATISTICS_V2")
+@RestController
+@RequestMapping("/v2/statistics")
+public class StatisticsV2Controller extends BaseController {
+
+    @Autowired
+    private DataAnalysisService dataAnalysisService;
+
+    /**
+     * query all workflow count
+     * @param loginUser login user
+     * @return workflow count
+     */
+    @Operation(summary = "queryAllWorkflowCount", description = "QUERY_ALL_WORKFLOW_COUNT")
+    @GetMapping(value = "/workflows/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_ALL_WORKFLOW_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryWorkflowInstanceCounts(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser) {
+        Map<String, Object> result = dataAnalysisService.queryAllWorkflowCounts(loginUser);
+        return returnDataList(result);
+    }
+
+    /**
+     * query all workflow States count
+     * @param loginUser login user
+     * @param statisticsStateRequest statisticsStateRequest
+     * @return workflow States count
+     */
+    @Operation(summary = "queryAllWorkflowStatesCount", description = "QUERY_ALL_WORKFLOW_STATES_COUNT")
+    @GetMapping(value = "/workflows/states/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_WORKFLOW_STATES_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryWorkflowStatesCounts(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                            @RequestBody(required = false) StatisticsStateRequest statisticsStateRequest) {
+        Map<String, Object> result =
+                dataAnalysisService.countWorkflowStates(loginUser, statisticsStateRequest);
+        return returnDataList(result);
+    }
+
+    /**
+     * query one workflow States count
+     * @param loginUser login user
+     * @param workflowCode workflowCode
+     * @return workflow States count
+     */
+    @Operation(summary = "queryOneWorkflowStatesCount", description = "QUERY_One_WORKFLOW_STATES_COUNT")
+    @GetMapping(value = "/{workflowCode}/states/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_ONE_WORKFLOW_STATE_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryOneWorkflowStates(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                         @PathVariable("workflowCode") Long workflowCode) {
+        Map<String, Object> result =
+                dataAnalysisService.countOneWorkflowStates(loginUser, workflowCode);
+        return returnDataList(result);
+    }
+
+    /**
+     * query all task States count
+     * @param loginUser login user
+     * @param statisticsStateRequest statisticsStateRequest
+     * @return tasks States count
+     */
+    @Operation(summary = "queryAllTaskStatesCount", description = "QUERY_ALL_TASK_STATES_COUNT")
+    @GetMapping(value = "/tasks/states/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_TASK_STATES_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryTaskStatesCounts(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                        @RequestBody(required = false) StatisticsStateRequest statisticsStateRequest) {
+        Map<String, Object> result =
+                dataAnalysisService.countTaskStates(loginUser, statisticsStateRequest);
+        return returnDataList(result);
+    }
+
+    /**
+     * query one task States count

Review Comment:
   ```suggestion
        * query one task states count
   ```



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/project/StatisticsStateRequest.java:
##########
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.api.dto.project;
+
+import java.util.Date;
+
+import lombok.Data;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import io.swagger.v3.oas.annotations.media.Schema;
+
+@Data
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class StatisticsStateRequest {
+
+    @Schema(name = "isAll", example = "true")
+    boolean isAll;
+
+    @Schema(name = "projectName", example = "PROJECT-NAME")
+    String projectName;
+
+    @Schema(name = "projectCode", example = "PROJECT-CODE")

Review Comment:
   we should use the code as code related parameter, same as workflow code
   ```suggestion
       @Schema(name = "projectCode", example = "1234567890")
   ```



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/StatisticsV2Controller.java:
##########
@@ -0,0 +1,209 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.api.controller;
+
+import static org.apache.dolphinscheduler.api.enums.Status.COUNT_PROCESS_DEFINITION_USER_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ALL_WORKFLOW_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ONE_TASK_STATES_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ONE_WORKFLOW_STATE_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_TASK_STATES_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_WORKFLOW_STATES_COUNT_ERROR;
+
+import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
+import org.apache.dolphinscheduler.api.dto.project.StatisticsStateRequest;
+import org.apache.dolphinscheduler.api.exceptions.ApiException;
+import org.apache.dolphinscheduler.api.service.DataAnalysisService;
+import org.apache.dolphinscheduler.api.utils.Result;
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.dao.entity.User;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.Map;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestAttribute;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestController;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
+/**
+ * StatisticsV2 controller
+ */
+@Tag(name = "STATISTICS_V2")
+@RestController
+@RequestMapping("/v2/statistics")
+public class StatisticsV2Controller extends BaseController {
+
+    @Autowired
+    private DataAnalysisService dataAnalysisService;
+
+    /**
+     * query all workflow count
+     * @param loginUser login user
+     * @return workflow count
+     */
+    @Operation(summary = "queryAllWorkflowCount", description = "QUERY_ALL_WORKFLOW_COUNT")
+    @GetMapping(value = "/workflows/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_ALL_WORKFLOW_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryWorkflowInstanceCounts(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser) {
+        Map<String, Object> result = dataAnalysisService.queryAllWorkflowCounts(loginUser);
+        return returnDataList(result);
+    }
+
+    /**
+     * query all workflow States count
+     * @param loginUser login user
+     * @param statisticsStateRequest statisticsStateRequest
+     * @return workflow States count
+     */
+    @Operation(summary = "queryAllWorkflowStatesCount", description = "QUERY_ALL_WORKFLOW_STATES_COUNT")
+    @GetMapping(value = "/workflows/states/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_WORKFLOW_STATES_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryWorkflowStatesCounts(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                            @RequestBody(required = false) StatisticsStateRequest statisticsStateRequest) {
+        Map<String, Object> result =
+                dataAnalysisService.countWorkflowStates(loginUser, statisticsStateRequest);
+        return returnDataList(result);
+    }
+
+    /**
+     * query one workflow States count
+     * @param loginUser login user
+     * @param workflowCode workflowCode
+     * @return workflow States count
+     */
+    @Operation(summary = "queryOneWorkflowStatesCount", description = "QUERY_One_WORKFLOW_STATES_COUNT")
+    @GetMapping(value = "/{workflowCode}/states/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_ONE_WORKFLOW_STATE_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryOneWorkflowStates(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                         @PathVariable("workflowCode") Long workflowCode) {
+        Map<String, Object> result =
+                dataAnalysisService.countOneWorkflowStates(loginUser, workflowCode);
+        return returnDataList(result);
+    }
+
+    /**
+     * query all task States count
+     * @param loginUser login user
+     * @param statisticsStateRequest statisticsStateRequest
+     * @return tasks States count
+     */
+    @Operation(summary = "queryAllTaskStatesCount", description = "QUERY_ALL_TASK_STATES_COUNT")
+    @GetMapping(value = "/tasks/states/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_TASK_STATES_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryTaskStatesCounts(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                        @RequestBody(required = false) StatisticsStateRequest statisticsStateRequest) {
+        Map<String, Object> result =
+                dataAnalysisService.countTaskStates(loginUser, statisticsStateRequest);
+        return returnDataList(result);
+    }
+
+    /**
+     * query one task States count
+     * @param loginUser login user
+     * @param taskCode taskCode
+     * @return tasks States count

Review Comment:
   ```suggestion
        * @return tasks states count
   ```



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/StatisticsV2Controller.java:
##########
@@ -0,0 +1,209 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.api.controller;
+
+import static org.apache.dolphinscheduler.api.enums.Status.COUNT_PROCESS_DEFINITION_USER_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ALL_WORKFLOW_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ONE_TASK_STATES_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ONE_WORKFLOW_STATE_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_TASK_STATES_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_WORKFLOW_STATES_COUNT_ERROR;
+
+import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
+import org.apache.dolphinscheduler.api.dto.project.StatisticsStateRequest;
+import org.apache.dolphinscheduler.api.exceptions.ApiException;
+import org.apache.dolphinscheduler.api.service.DataAnalysisService;
+import org.apache.dolphinscheduler.api.utils.Result;
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.dao.entity.User;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.Map;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestAttribute;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestController;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
+/**
+ * StatisticsV2 controller
+ */
+@Tag(name = "STATISTICS_V2")
+@RestController
+@RequestMapping("/v2/statistics")
+public class StatisticsV2Controller extends BaseController {
+
+    @Autowired
+    private DataAnalysisService dataAnalysisService;
+
+    /**
+     * query all workflow count
+     * @param loginUser login user
+     * @return workflow count
+     */
+    @Operation(summary = "queryAllWorkflowCount", description = "QUERY_ALL_WORKFLOW_COUNT")
+    @GetMapping(value = "/workflows/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_ALL_WORKFLOW_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryWorkflowInstanceCounts(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser) {
+        Map<String, Object> result = dataAnalysisService.queryAllWorkflowCounts(loginUser);
+        return returnDataList(result);
+    }
+
+    /**
+     * query all workflow States count
+     * @param loginUser login user
+     * @param statisticsStateRequest statisticsStateRequest
+     * @return workflow States count
+     */
+    @Operation(summary = "queryAllWorkflowStatesCount", description = "QUERY_ALL_WORKFLOW_STATES_COUNT")
+    @GetMapping(value = "/workflows/states/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_WORKFLOW_STATES_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryWorkflowStatesCounts(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                            @RequestBody(required = false) StatisticsStateRequest statisticsStateRequest) {
+        Map<String, Object> result =
+                dataAnalysisService.countWorkflowStates(loginUser, statisticsStateRequest);
+        return returnDataList(result);
+    }
+
+    /**
+     * query one workflow States count
+     * @param loginUser login user
+     * @param workflowCode workflowCode
+     * @return workflow States count
+     */
+    @Operation(summary = "queryOneWorkflowStatesCount", description = "QUERY_One_WORKFLOW_STATES_COUNT")
+    @GetMapping(value = "/{workflowCode}/states/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_ONE_WORKFLOW_STATE_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryOneWorkflowStates(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                         @PathVariable("workflowCode") Long workflowCode) {
+        Map<String, Object> result =
+                dataAnalysisService.countOneWorkflowStates(loginUser, workflowCode);
+        return returnDataList(result);
+    }
+
+    /**
+     * query all task States count

Review Comment:
   ```suggestion
        * query all task states count
   ```



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/StatisticsV2Controller.java:
##########
@@ -0,0 +1,209 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.api.controller;
+
+import static org.apache.dolphinscheduler.api.enums.Status.COUNT_PROCESS_DEFINITION_USER_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ALL_WORKFLOW_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ONE_TASK_STATES_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ONE_WORKFLOW_STATE_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_TASK_STATES_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_WORKFLOW_STATES_COUNT_ERROR;
+
+import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
+import org.apache.dolphinscheduler.api.dto.project.StatisticsStateRequest;
+import org.apache.dolphinscheduler.api.exceptions.ApiException;
+import org.apache.dolphinscheduler.api.service.DataAnalysisService;
+import org.apache.dolphinscheduler.api.utils.Result;
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.dao.entity.User;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.Map;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestAttribute;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestController;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
+/**
+ * StatisticsV2 controller
+ */
+@Tag(name = "STATISTICS_V2")
+@RestController
+@RequestMapping("/v2/statistics")
+public class StatisticsV2Controller extends BaseController {
+
+    @Autowired
+    private DataAnalysisService dataAnalysisService;
+
+    /**
+     * query all workflow count
+     * @param loginUser login user
+     * @return workflow count
+     */
+    @Operation(summary = "queryAllWorkflowCount", description = "QUERY_ALL_WORKFLOW_COUNT")
+    @GetMapping(value = "/workflows/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_ALL_WORKFLOW_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryWorkflowInstanceCounts(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser) {
+        Map<String, Object> result = dataAnalysisService.queryAllWorkflowCounts(loginUser);
+        return returnDataList(result);
+    }
+
+    /**
+     * query all workflow States count
+     * @param loginUser login user
+     * @param statisticsStateRequest statisticsStateRequest
+     * @return workflow States count
+     */
+    @Operation(summary = "queryAllWorkflowStatesCount", description = "QUERY_ALL_WORKFLOW_STATES_COUNT")
+    @GetMapping(value = "/workflows/states/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_WORKFLOW_STATES_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryWorkflowStatesCounts(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                            @RequestBody(required = false) StatisticsStateRequest statisticsStateRequest) {
+        Map<String, Object> result =
+                dataAnalysisService.countWorkflowStates(loginUser, statisticsStateRequest);
+        return returnDataList(result);
+    }
+
+    /**
+     * query one workflow States count
+     * @param loginUser login user
+     * @param workflowCode workflowCode
+     * @return workflow States count
+     */
+    @Operation(summary = "queryOneWorkflowStatesCount", description = "QUERY_One_WORKFLOW_STATES_COUNT")
+    @GetMapping(value = "/{workflowCode}/states/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_ONE_WORKFLOW_STATE_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryOneWorkflowStates(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                         @PathVariable("workflowCode") Long workflowCode) {
+        Map<String, Object> result =
+                dataAnalysisService.countOneWorkflowStates(loginUser, workflowCode);
+        return returnDataList(result);
+    }
+
+    /**
+     * query all task States count
+     * @param loginUser login user
+     * @param statisticsStateRequest statisticsStateRequest
+     * @return tasks States count
+     */
+    @Operation(summary = "queryAllTaskStatesCount", description = "QUERY_ALL_TASK_STATES_COUNT")
+    @GetMapping(value = "/tasks/states/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_TASK_STATES_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryTaskStatesCounts(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                        @RequestBody(required = false) StatisticsStateRequest statisticsStateRequest) {
+        Map<String, Object> result =
+                dataAnalysisService.countTaskStates(loginUser, statisticsStateRequest);
+        return returnDataList(result);
+    }
+
+    /**
+     * query one task States count
+     * @param loginUser login user
+     * @param taskCode taskCode
+     * @return tasks States count
+     */
+    @Operation(summary = "queryOneTaskStatesCount", description = "QUERY_ONE_TASK_STATES_COUNT")
+    @GetMapping(value = "/tasks/{taskCode}/states/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_ONE_TASK_STATES_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryOneTaskStatesCounts(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                           @PathVariable("taskCode") Long taskCode) {
+        Map<String, Object> result =
+                dataAnalysisService.countOneTaskStates(loginUser, taskCode);
+        return returnDataList(result);
+    }
+
+    /**
+     * statistics the process definition quantities of certain person
+     *
+     * @param loginUser login user
+     * @param statisticsStateRequest statisticsStateRequest
+     * @return definition count in project code

Review Comment:
   ```suggestion
        * @return workflow count in project code
   ```



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/StatisticsV2Controller.java:
##########
@@ -0,0 +1,209 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.api.controller;
+
+import static org.apache.dolphinscheduler.api.enums.Status.COUNT_PROCESS_DEFINITION_USER_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ALL_WORKFLOW_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ONE_TASK_STATES_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ONE_WORKFLOW_STATE_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_TASK_STATES_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_WORKFLOW_STATES_COUNT_ERROR;
+
+import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
+import org.apache.dolphinscheduler.api.dto.project.StatisticsStateRequest;
+import org.apache.dolphinscheduler.api.exceptions.ApiException;
+import org.apache.dolphinscheduler.api.service.DataAnalysisService;
+import org.apache.dolphinscheduler.api.utils.Result;
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.dao.entity.User;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.Map;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestAttribute;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestController;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
+/**
+ * StatisticsV2 controller
+ */
+@Tag(name = "STATISTICS_V2")
+@RestController
+@RequestMapping("/v2/statistics")
+public class StatisticsV2Controller extends BaseController {
+
+    @Autowired
+    private DataAnalysisService dataAnalysisService;
+
+    /**
+     * query all workflow count
+     * @param loginUser login user
+     * @return workflow count
+     */
+    @Operation(summary = "queryAllWorkflowCount", description = "QUERY_ALL_WORKFLOW_COUNT")
+    @GetMapping(value = "/workflows/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_ALL_WORKFLOW_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryWorkflowInstanceCounts(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser) {
+        Map<String, Object> result = dataAnalysisService.queryAllWorkflowCounts(loginUser);
+        return returnDataList(result);
+    }
+
+    /**
+     * query all workflow States count
+     * @param loginUser login user
+     * @param statisticsStateRequest statisticsStateRequest
+     * @return workflow States count
+     */
+    @Operation(summary = "queryAllWorkflowStatesCount", description = "QUERY_ALL_WORKFLOW_STATES_COUNT")
+    @GetMapping(value = "/workflows/states/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_WORKFLOW_STATES_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryWorkflowStatesCounts(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                            @RequestBody(required = false) StatisticsStateRequest statisticsStateRequest) {
+        Map<String, Object> result =
+                dataAnalysisService.countWorkflowStates(loginUser, statisticsStateRequest);
+        return returnDataList(result);
+    }
+
+    /**
+     * query one workflow States count
+     * @param loginUser login user
+     * @param workflowCode workflowCode
+     * @return workflow States count
+     */
+    @Operation(summary = "queryOneWorkflowStatesCount", description = "QUERY_One_WORKFLOW_STATES_COUNT")
+    @GetMapping(value = "/{workflowCode}/states/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_ONE_WORKFLOW_STATE_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryOneWorkflowStates(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                         @PathVariable("workflowCode") Long workflowCode) {
+        Map<String, Object> result =
+                dataAnalysisService.countOneWorkflowStates(loginUser, workflowCode);
+        return returnDataList(result);
+    }
+
+    /**
+     * query all task States count
+     * @param loginUser login user
+     * @param statisticsStateRequest statisticsStateRequest
+     * @return tasks States count
+     */
+    @Operation(summary = "queryAllTaskStatesCount", description = "QUERY_ALL_TASK_STATES_COUNT")
+    @GetMapping(value = "/tasks/states/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_TASK_STATES_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryTaskStatesCounts(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                        @RequestBody(required = false) StatisticsStateRequest statisticsStateRequest) {
+        Map<String, Object> result =
+                dataAnalysisService.countTaskStates(loginUser, statisticsStateRequest);
+        return returnDataList(result);
+    }
+
+    /**
+     * query one task States count
+     * @param loginUser login user
+     * @param taskCode taskCode
+     * @return tasks States count
+     */
+    @Operation(summary = "queryOneTaskStatesCount", description = "QUERY_ONE_TASK_STATES_COUNT")
+    @GetMapping(value = "/tasks/{taskCode}/states/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_ONE_TASK_STATES_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryOneTaskStatesCounts(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                           @PathVariable("taskCode") Long taskCode) {
+        Map<String, Object> result =
+                dataAnalysisService.countOneTaskStates(loginUser, taskCode);
+        return returnDataList(result);
+    }
+
+    /**
+     * statistics the process definition quantities of certain person
+     *
+     * @param loginUser login user
+     * @param statisticsStateRequest statisticsStateRequest
+     * @return definition count in project code
+     */
+    @Operation(summary = "countDefinitionV2ByUserId", description = "COUNT_PROCESS_DEFINITION_V2_BY_USERID_NOTES")
+    @GetMapping(value = "/workflows/users/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(COUNT_PROCESS_DEFINITION_USER_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result countDefinitionByUser(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                        @RequestBody(required = false) StatisticsStateRequest statisticsStateRequest) {
+        String projectName = statisticsStateRequest.getProjectName();
+        Long projectCode = statisticsStateRequest.getProjectCode();
+        if (null == projectCode && !StringUtils.isBlank(projectName)) {
+            projectCode = dataAnalysisService.getProjectCodeByName(projectName);
+        }
+        Map<String, Object> result = dataAnalysisService.countDefinitionByUserV2(loginUser, projectCode, null, null);
+        return returnDataList(result);
+    }
+
+    /**
+     * statistics the process definition quantities of certain userId
+     *
+     * @param loginUser login user
+     * @param userId userId
+     * @return definition count in project code
+     */
+    @Operation(summary = "countDefinitionV2ByUser", description = "COUNT_PROCESS_DEFINITION_V2_BY_USER_NOTES")
+    @GetMapping(value = "/workflows/users/{userId}/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(COUNT_PROCESS_DEFINITION_USER_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result countDefinitionByUserId(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                          @PathVariable("userId") Integer userId) {
+        Map<String, Object> result = dataAnalysisService.countDefinitionByUserV2(loginUser, null, userId, null);
+        return returnDataList(result);
+    }
+    /**
+    * statistics the process definition quantities of certain userId filter releaseState

Review Comment:
   ```suggestion
       * statistics the workflow quantities of certain userId filter releaseState
   ```



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/StatisticsV2Controller.java:
##########
@@ -0,0 +1,209 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.api.controller;
+
+import static org.apache.dolphinscheduler.api.enums.Status.COUNT_PROCESS_DEFINITION_USER_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ALL_WORKFLOW_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ONE_TASK_STATES_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ONE_WORKFLOW_STATE_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_TASK_STATES_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_WORKFLOW_STATES_COUNT_ERROR;
+
+import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
+import org.apache.dolphinscheduler.api.dto.project.StatisticsStateRequest;
+import org.apache.dolphinscheduler.api.exceptions.ApiException;
+import org.apache.dolphinscheduler.api.service.DataAnalysisService;
+import org.apache.dolphinscheduler.api.utils.Result;
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.dao.entity.User;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.Map;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestAttribute;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestController;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
+/**
+ * StatisticsV2 controller
+ */
+@Tag(name = "STATISTICS_V2")
+@RestController
+@RequestMapping("/v2/statistics")
+public class StatisticsV2Controller extends BaseController {
+
+    @Autowired
+    private DataAnalysisService dataAnalysisService;
+
+    /**
+     * query all workflow count
+     * @param loginUser login user
+     * @return workflow count
+     */
+    @Operation(summary = "queryAllWorkflowCount", description = "QUERY_ALL_WORKFLOW_COUNT")
+    @GetMapping(value = "/workflows/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_ALL_WORKFLOW_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryWorkflowInstanceCounts(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser) {
+        Map<String, Object> result = dataAnalysisService.queryAllWorkflowCounts(loginUser);
+        return returnDataList(result);
+    }
+
+    /**
+     * query all workflow States count
+     * @param loginUser login user
+     * @param statisticsStateRequest statisticsStateRequest
+     * @return workflow States count
+     */
+    @Operation(summary = "queryAllWorkflowStatesCount", description = "QUERY_ALL_WORKFLOW_STATES_COUNT")
+    @GetMapping(value = "/workflows/states/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_WORKFLOW_STATES_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryWorkflowStatesCounts(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                            @RequestBody(required = false) StatisticsStateRequest statisticsStateRequest) {
+        Map<String, Object> result =
+                dataAnalysisService.countWorkflowStates(loginUser, statisticsStateRequest);
+        return returnDataList(result);
+    }
+
+    /**
+     * query one workflow States count
+     * @param loginUser login user
+     * @param workflowCode workflowCode
+     * @return workflow States count
+     */
+    @Operation(summary = "queryOneWorkflowStatesCount", description = "QUERY_One_WORKFLOW_STATES_COUNT")
+    @GetMapping(value = "/{workflowCode}/states/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_ONE_WORKFLOW_STATE_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryOneWorkflowStates(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                         @PathVariable("workflowCode") Long workflowCode) {
+        Map<String, Object> result =
+                dataAnalysisService.countOneWorkflowStates(loginUser, workflowCode);
+        return returnDataList(result);
+    }
+
+    /**
+     * query all task States count
+     * @param loginUser login user
+     * @param statisticsStateRequest statisticsStateRequest
+     * @return tasks States count
+     */
+    @Operation(summary = "queryAllTaskStatesCount", description = "QUERY_ALL_TASK_STATES_COUNT")
+    @GetMapping(value = "/tasks/states/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_TASK_STATES_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryTaskStatesCounts(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                        @RequestBody(required = false) StatisticsStateRequest statisticsStateRequest) {
+        Map<String, Object> result =
+                dataAnalysisService.countTaskStates(loginUser, statisticsStateRequest);
+        return returnDataList(result);
+    }
+
+    /**
+     * query one task States count
+     * @param loginUser login user
+     * @param taskCode taskCode
+     * @return tasks States count
+     */
+    @Operation(summary = "queryOneTaskStatesCount", description = "QUERY_ONE_TASK_STATES_COUNT")
+    @GetMapping(value = "/tasks/{taskCode}/states/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_ONE_TASK_STATES_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryOneTaskStatesCounts(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                           @PathVariable("taskCode") Long taskCode) {
+        Map<String, Object> result =
+                dataAnalysisService.countOneTaskStates(loginUser, taskCode);
+        return returnDataList(result);
+    }
+
+    /**
+     * statistics the process definition quantities of certain person
+     *
+     * @param loginUser login user
+     * @param statisticsStateRequest statisticsStateRequest
+     * @return definition count in project code
+     */
+    @Operation(summary = "countDefinitionV2ByUserId", description = "COUNT_PROCESS_DEFINITION_V2_BY_USERID_NOTES")
+    @GetMapping(value = "/workflows/users/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(COUNT_PROCESS_DEFINITION_USER_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result countDefinitionByUser(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                        @RequestBody(required = false) StatisticsStateRequest statisticsStateRequest) {
+        String projectName = statisticsStateRequest.getProjectName();
+        Long projectCode = statisticsStateRequest.getProjectCode();
+        if (null == projectCode && !StringUtils.isBlank(projectName)) {
+            projectCode = dataAnalysisService.getProjectCodeByName(projectName);
+        }
+        Map<String, Object> result = dataAnalysisService.countDefinitionByUserV2(loginUser, projectCode, null, null);
+        return returnDataList(result);
+    }
+
+    /**
+     * statistics the process definition quantities of certain userId
+     *
+     * @param loginUser login user
+     * @param userId userId
+     * @return definition count in project code

Review Comment:
   ```suggestion
        * @return workflow count in project code
   ```



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataAnalysisServiceImpl.java:
##########
@@ -353,4 +359,250 @@ public List<ExecuteStatusCount> countTaskInstanceAllStatesByProjectCodes(Date st
 
         return startTimeStates.orElse(null);
     }
+    /**
+     * query all workflow count
+     *
+     * @param loginUser login user
+     * @return workflow count
+     */
+    @Override
+    public Map<String, Object> queryAllWorkflowCounts(User loginUser) {
+        Map<String, Object> result = new HashMap<>();
+        int count = 0;
+        Set<Integer> projectIds = resourcePermissionCheckService
+                .userOwnedResourceIdsAcquisition(AuthorizationType.PROJECTS, loginUser.getId(), logger);
+        if (!projectIds.isEmpty()) {
+            List<Project> projects = projectMapper.selectBatchIds(projectIds);
+            List<Long> projectCodes = projects.stream().map(project -> project.getCode()).collect(Collectors.toList());
+            count = projectMapper.queryAllWorkflowCounts(projectCodes);
+        }
+        result.put("data", "AllWorkflowCounts = " + count);
+        putMsg(result, Status.SUCCESS);
+        return result;
+    }
+
+    /**
+     * query all workflow States count
+     * @param loginUser login user
+     * @param statisticsStateRequest statisticsStateRequest
+     * @return workflow States count
+     */
+    @Override
+    public Map<String, Object> countWorkflowStates(User loginUser,
+                                                   StatisticsStateRequest statisticsStateRequest) {
+        Map<String, Object> result = new HashMap<>();
+        Set<Integer> projectIds = resourcePermissionCheckService
+                .userOwnedResourceIdsAcquisition(AuthorizationType.PROJECTS, loginUser.getId(), logger);
+        if (projectIds.isEmpty()) {
+            putMsg(result, Status.SUCCESS);
+            return result;
+        }
+
+        String projectName = statisticsStateRequest.getProjectName();
+        String workflowName = statisticsStateRequest.getWorkflowName();
+        Long projectCode = statisticsStateRequest.getProjectCode();
+        Long workflowCode = statisticsStateRequest.getWorkflowCode();
+        Integer model = Constants.QUERY_ALL_ON_SYSTEM;
+
+        if (!StringUtils.isBlank(projectName) || null != projectCode) {
+            model = Constants.QUERY_ALL_ON_PROJECT;
+        }
+        if (!StringUtils.isBlank(workflowName) || null != workflowCode) {
+            model = Constants.QUERY_ALL_ON_WORKFLOW;
+        }
+        try {
+            if (null == workflowCode || null == projectCode) {
+                projectCode = projectMapper.queryByName(projectName).getCode();
+                workflowCode = processDefinitionMapper.queryByDefineName(projectCode, workflowName).getCode();
+            }
+        } catch (Exception e) {
+
+        }

Review Comment:
   same as this exception



##########
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProcessTaskRelationMapper.xml:
##########
@@ -221,6 +221,13 @@
         </where>
         order by update_time desc, id asc
     </select>
+    <select id="queryTaskCodeByTaskName" resultType="java.lang.Long">

Review Comment:
   It is seem we support  same task name in one single workflow currently



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/StatisticsV2Controller.java:
##########
@@ -0,0 +1,209 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.api.controller;
+
+import static org.apache.dolphinscheduler.api.enums.Status.COUNT_PROCESS_DEFINITION_USER_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ALL_WORKFLOW_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ONE_TASK_STATES_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ONE_WORKFLOW_STATE_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_TASK_STATES_COUNT_ERROR;
+import static org.apache.dolphinscheduler.api.enums.Status.QUERY_WORKFLOW_STATES_COUNT_ERROR;
+
+import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
+import org.apache.dolphinscheduler.api.dto.project.StatisticsStateRequest;
+import org.apache.dolphinscheduler.api.exceptions.ApiException;
+import org.apache.dolphinscheduler.api.service.DataAnalysisService;
+import org.apache.dolphinscheduler.api.utils.Result;
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.dao.entity.User;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.Map;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestAttribute;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestController;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
+/**
+ * StatisticsV2 controller
+ */
+@Tag(name = "STATISTICS_V2")
+@RestController
+@RequestMapping("/v2/statistics")
+public class StatisticsV2Controller extends BaseController {
+
+    @Autowired
+    private DataAnalysisService dataAnalysisService;
+
+    /**
+     * query all workflow count
+     * @param loginUser login user
+     * @return workflow count
+     */
+    @Operation(summary = "queryAllWorkflowCount", description = "QUERY_ALL_WORKFLOW_COUNT")
+    @GetMapping(value = "/workflows/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_ALL_WORKFLOW_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryWorkflowInstanceCounts(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser) {
+        Map<String, Object> result = dataAnalysisService.queryAllWorkflowCounts(loginUser);
+        return returnDataList(result);
+    }
+
+    /**
+     * query all workflow States count
+     * @param loginUser login user
+     * @param statisticsStateRequest statisticsStateRequest
+     * @return workflow States count
+     */
+    @Operation(summary = "queryAllWorkflowStatesCount", description = "QUERY_ALL_WORKFLOW_STATES_COUNT")
+    @GetMapping(value = "/workflows/states/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_WORKFLOW_STATES_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryWorkflowStatesCounts(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                            @RequestBody(required = false) StatisticsStateRequest statisticsStateRequest) {
+        Map<String, Object> result =
+                dataAnalysisService.countWorkflowStates(loginUser, statisticsStateRequest);
+        return returnDataList(result);
+    }
+
+    /**
+     * query one workflow States count
+     * @param loginUser login user
+     * @param workflowCode workflowCode
+     * @return workflow States count
+     */
+    @Operation(summary = "queryOneWorkflowStatesCount", description = "QUERY_One_WORKFLOW_STATES_COUNT")
+    @GetMapping(value = "/{workflowCode}/states/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_ONE_WORKFLOW_STATE_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryOneWorkflowStates(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                         @PathVariable("workflowCode") Long workflowCode) {
+        Map<String, Object> result =
+                dataAnalysisService.countOneWorkflowStates(loginUser, workflowCode);
+        return returnDataList(result);
+    }
+
+    /**
+     * query all task States count
+     * @param loginUser login user
+     * @param statisticsStateRequest statisticsStateRequest
+     * @return tasks States count
+     */
+    @Operation(summary = "queryAllTaskStatesCount", description = "QUERY_ALL_TASK_STATES_COUNT")
+    @GetMapping(value = "/tasks/states/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_TASK_STATES_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryTaskStatesCounts(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                        @RequestBody(required = false) StatisticsStateRequest statisticsStateRequest) {
+        Map<String, Object> result =
+                dataAnalysisService.countTaskStates(loginUser, statisticsStateRequest);
+        return returnDataList(result);
+    }
+
+    /**
+     * query one task States count
+     * @param loginUser login user
+     * @param taskCode taskCode
+     * @return tasks States count
+     */
+    @Operation(summary = "queryOneTaskStatesCount", description = "QUERY_ONE_TASK_STATES_COUNT")
+    @GetMapping(value = "/tasks/{taskCode}/states/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(QUERY_ONE_TASK_STATES_COUNT_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result queryOneTaskStatesCounts(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                           @PathVariable("taskCode") Long taskCode) {
+        Map<String, Object> result =
+                dataAnalysisService.countOneTaskStates(loginUser, taskCode);
+        return returnDataList(result);
+    }
+
+    /**
+     * statistics the process definition quantities of certain person
+     *
+     * @param loginUser login user
+     * @param statisticsStateRequest statisticsStateRequest
+     * @return definition count in project code
+     */
+    @Operation(summary = "countDefinitionV2ByUserId", description = "COUNT_PROCESS_DEFINITION_V2_BY_USERID_NOTES")
+    @GetMapping(value = "/workflows/users/count")
+    @ResponseStatus(HttpStatus.OK)
+    @ApiException(COUNT_PROCESS_DEFINITION_USER_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result countDefinitionByUser(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+                                        @RequestBody(required = false) StatisticsStateRequest statisticsStateRequest) {
+        String projectName = statisticsStateRequest.getProjectName();
+        Long projectCode = statisticsStateRequest.getProjectCode();
+        if (null == projectCode && !StringUtils.isBlank(projectName)) {
+            projectCode = dataAnalysisService.getProjectCodeByName(projectName);
+        }
+        Map<String, Object> result = dataAnalysisService.countDefinitionByUserV2(loginUser, projectCode, null, null);
+        return returnDataList(result);
+    }
+
+    /**
+     * statistics the process definition quantities of certain userId

Review Comment:
   ```suggestion
        * statistics the workflow quantities of certain userId
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [dolphinscheduler] codecov-commenter commented on pull request #13031: [Feature][API] New restful API for workflow state

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #13031:
URL: https://github.com/apache/dolphinscheduler/pull/13031#issuecomment-1331506620

   # [Codecov](https://codecov.io/gh/apache/dolphinscheduler/pull/13031?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#13031](https://codecov.io/gh/apache/dolphinscheduler/pull/13031?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (bc60c8c) into [dev](https://codecov.io/gh/apache/dolphinscheduler/commit/a0eb45b9e4e3beb6a3ff77e72d3a1ca806a956bd?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (a0eb45b) will **decrease** coverage by `0.17%`.
   > The diff coverage is `5.40%`.
   
   ```diff
   @@             Coverage Diff              @@
   ##                dev   #13031      +/-   ##
   ============================================
   - Coverage     39.33%   39.16%   -0.18%     
   + Complexity     4276     4273       -3     
   ============================================
     Files          1069     1069              
     Lines         40187    40324     +137     
     Branches       4613     4620       +7     
   ============================================
   - Hits          15809    15793      -16     
   - Misses        22600    22756     +156     
   + Partials       1778     1775       -3     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/dolphinscheduler/pull/13031?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...uler/api/service/impl/DataAnalysisServiceImpl.java](https://codecov.io/gh/apache/dolphinscheduler/pull/13031/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1hcGkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvYXBpL3NlcnZpY2UvaW1wbC9EYXRhQW5hbHlzaXNTZXJ2aWNlSW1wbC5qYXZh) | `36.63% <0.00%> (-45.34%)` | :arrow_down: |
   | [...scheduler/api/service/impl/ProjectServiceImpl.java](https://codecov.io/gh/apache/dolphinscheduler/pull/13031/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1hcGkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvYXBpL3NlcnZpY2UvaW1wbC9Qcm9qZWN0U2VydmljZUltcGwuamF2YQ==) | `62.79% <ø> (ø)` | |
   | [...heduler/api/controller/StatisticsV2Controller.java](https://codecov.io/gh/apache/dolphinscheduler/pull/13031/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1hcGkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvYXBpL2NvbnRyb2xsZXIvU3RhdGlzdGljc1YyQ29udHJvbGxlci5qYXZh) | `4.00% <4.00%> (ø)` | |
   | [.../org/apache/dolphinscheduler/api/enums/Status.java](https://codecov.io/gh/apache/dolphinscheduler/pull/13031/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1hcGkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvYXBpL2VudW1zL1N0YXR1cy5qYXZh) | `100.00% <100.00%> (ø)` | |
   | [...e/dolphinscheduler/common/constants/Constants.java](https://codecov.io/gh/apache/dolphinscheduler/pull/13031/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvY29tbW9uL2NvbnN0YW50cy9Db25zdGFudHMuamF2YQ==) | `75.00% <100.00%> (+12.50%)` | :arrow_up: |
   | [...erver/master/processor/queue/TaskEventService.java](https://codecov.io/gh/apache/dolphinscheduler/pull/13031/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1tYXN0ZXIvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvc2VydmVyL21hc3Rlci9wcm9jZXNzb3IvcXVldWUvVGFza0V2ZW50U2VydmljZS5qYXZh) | `75.00% <0.00%> (-5.36%)` | :arrow_down: |
   | [...hinscheduler/plugin/alert/script/ScriptSender.java](https://codecov.io/gh/apache/dolphinscheduler/pull/13031/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1hbGVydC9kb2xwaGluc2NoZWR1bGVyLWFsZXJ0LXBsdWdpbnMvZG9scGhpbnNjaGVkdWxlci1hbGVydC1zY3JpcHQvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvcGx1Z2luL2FsZXJ0L3NjcmlwdC9TY3JpcHRTZW5kZXIuamF2YQ==) | `70.58% <0.00%> (-1.64%)` | :arrow_down: |
   | [...erver/worker/runner/WorkerTaskExecuteRunnable.java](https://codecov.io/gh/apache/dolphinscheduler/pull/13031/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci13b3JrZXIvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvc2VydmVyL3dvcmtlci9ydW5uZXIvV29ya2VyVGFza0V4ZWN1dGVSdW5uYWJsZS5qYXZh) | `38.51% <0.00%> (-1.23%)` | :arrow_down: |
   | [...r/plugin/task/sqoop/parameter/SqoopParameters.java](https://codecov.io/gh/apache/dolphinscheduler/pull/13031/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci10YXNrLXBsdWdpbi9kb2xwaGluc2NoZWR1bGVyLXRhc2stc3Fvb3Avc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvcGx1Z2luL3Rhc2svc3Fvb3AvcGFyYW1ldGVyL1Nxb29wUGFyYW1ldGVycy5qYXZh) | `51.19% <0.00%> (-1.20%)` | :arrow_down: |
   | [...cheduler/plugin/alert/dingtalk/DingTalkSender.java](https://codecov.io/gh/apache/dolphinscheduler/pull/13031/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1hbGVydC9kb2xwaGluc2NoZWR1bGVyLWFsZXJ0LXBsdWdpbnMvZG9scGhpbnNjaGVkdWxlci1hbGVydC1kaW5ndGFsay9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZG9scGhpbnNjaGVkdWxlci9wbHVnaW4vYWxlcnQvZGluZ3RhbGsvRGluZ1RhbGtTZW5kZXIuamF2YQ==) | `34.13% <0.00%> (-0.78%)` | :arrow_down: |
   | ... and [22 more](https://codecov.io/gh/apache/dolphinscheduler/pull/13031/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #13031: [Feature][API] New restful API for workflow state

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #13031:
URL: https://github.com/apache/dolphinscheduler/pull/13031#issuecomment-1329553319

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=13031)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=CODE_SMELL) [9 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=CODE_SMELL)
   
   [![6.4%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '6.4%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=13031&metric=new_coverage&view=list) [6.4% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=13031&metric=new_coverage&view=list)  
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=13031&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=13031&metric=new_duplicated_lines_density&view=list)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [dolphinscheduler] insist777 commented on a diff in pull request #13031: [Feature][API] New restful API for workflow state

Posted by GitBox <gi...@apache.org>.
insist777 commented on code in PR #13031:
URL: https://github.com/apache/dolphinscheduler/pull/13031#discussion_r1035413516


##########
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProcessInstanceMapper.xml:
##########
@@ -308,6 +308,30 @@
         </if>
         order by instance.start_time desc,instance.id desc
     </select>
+    <select id="countInstanceStateV2" resultType="org.apache.dolphinscheduler.dao.entity.ExecuteStatusCount">
+        select t.state, count(0) as count
+        from t_ds_process_instance t
+        join t_ds_process_definition d on d.code=t.process_definition_code
+        join t_ds_project p on p.code=d.project_code
+        where 1 = 1
+        and t.is_sub_process = 0
+        <if test="projectIds != null and projectIds.size() != 0">
+            and p.id in
+            <foreach collection="projectIds" index="index" item="i" open="(" close=")" separator=",">
+                #{i}
+            </foreach>
+        </if>
+        <if test="startTime != null and endTime != null">
+            and t.start_time <![CDATA[ >= ]]> #{startTime} and t.start_time <![CDATA[ <= ]]> #{endTime}
+        </if>
+        <if test="model >= 1">
+           and p.name = #{projectName}
+        </if>
+        <if test="model >= 2">
+            and d.name = #{workflowName}

Review Comment:
   done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #13031: [Feature][API] New restful API for workflow state

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #13031:
URL: https://github.com/apache/dolphinscheduler/pull/13031#issuecomment-1331509064

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=13031)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=BUG) [![C](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/C-16px.png 'C')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=BUG) [2 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=CODE_SMELL) [15 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=CODE_SMELL)
   
   [![3.8%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '3.8%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=13031&metric=new_coverage&view=list) [3.8% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=13031&metric=new_coverage&view=list)  
   [![2.2%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '2.2%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=13031&metric=new_duplicated_lines_density&view=list) [2.2% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=13031&metric=new_duplicated_lines_density&view=list)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #13031: [Feature][API] New restful API for workflow state

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #13031:
URL: https://github.com/apache/dolphinscheduler/pull/13031#issuecomment-1329550721

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=13031)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=CODE_SMELL) [9 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=13031&resolved=false&types=CODE_SMELL)
   
   [![6.4%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '6.4%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=13031&metric=new_coverage&view=list) [6.4% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=13031&metric=new_coverage&view=list)  
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=13031&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=13031&metric=new_duplicated_lines_density&view=list)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org