feat(周报功能重构):周报个人统计、项目组统计

This commit is contained in:
wanjia 2025-05-22 09:57:23 +08:00
parent 562469eccb
commit 71e5c84a1a
11 changed files with 142 additions and 1 deletions

View File

@ -41,6 +41,28 @@ public class PmsProjectWeeklyReportController {
return success(result);
}
/**
* 查询周报-个人工作项统计
*/
@GetMapping("/personal")
@ApiOperation(value = "周报-个人工作项统计")
public AjaxResult getPersonalWeeklyReport(@PathVariable String enterpriseIdentifier)
{
JSONObject result = pmsProjectIssuesService.getPersonalIssuesStatistics(enterpriseIdentifier);
return success(result);
}
/**
* 查询周报-项目组工作项统计
*/
@GetMapping("/projectTeam")
@ApiOperation(value = "周报-项目组工作项统计")
public AjaxResult getProjectTeamWeeklyReport(@PathVariable String enterpriseIdentifier)
{
JSONObject result = pmsProjectIssuesService.getProjectTeamIssuesStatistics(enterpriseIdentifier);
return success(result);
}
/**
* 新增项目项目周报
*/

View File

@ -89,4 +89,6 @@ public interface PmsProjectMapper
void updatePmsProjectNoProduct(@Param("projectIdList") List<Long> projectIdList);
PmsProject selectPmsProjectById(Long id);
List<Long> selectProjectIdsByAssigneeUserId(@Param("enterpriseIdentifier") String enterpriseIdentifier, @Param("gitlinkUserId") Long gitlinkUserId);
}

View File

@ -80,4 +80,8 @@ public interface PmsProjectSprintMapper
Integer selectOpeningSprintLastWeekIterationCount(@Param("pmProjectId") Long pmProjectId);
PmsProjectSprintStatisticsVo selectPmsProjectSprintStatisticsByProjectId(@Param("pmProjectId") Long pmProjectId);
int selectNewSprintCurrentNaturalWeekCount(@Param("projectId") Long projectId);
int selectCompleteSprintCurrentNaturalWeekCount(@Param("projectId") Long projectId);
}

View File

@ -68,4 +68,8 @@ public interface PmsProjectTestsheetMapper
int deletePmsProjectTestsheetByProjectId(@Param("projectId") Long projectId);
Integer selectCountBySprintId(@Param("sprintId") Long sprintId);
int selectNewTestSheetCurrentNaturalWeekCount(@Param("projectId") Long projectId);
int selectCompleteTestSheetCurrentNaturalWeekCount(@Param("projectId") Long projectId);
}

View File

@ -5,7 +5,6 @@ import com.microservices.common.core.web.page.GenericsTableDataInfo;
import com.microservices.pms.project.domain.PmsProject;
import com.microservices.pms.project.domain.vo.*;
import com.microservices.system.api.domain.SimpleSysUser;
import com.microservices.system.api.domain.SysNotice;
import java.util.List;
@ -100,4 +99,6 @@ public interface IPmsProjectService
JSONObject getMyRepositoriesStatistics(Long repositoryId);
PmsProject selectPmsProjectByIdNoCheckRole(Long pmsProjectId);
List<Long> selectProjectIdsByAssigneeUserId(String enterpriseIdentifier, Long gitlinkUserId);
}

View File

@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.microservices.common.core.exception.ServiceException;
import com.microservices.common.core.utils.DateUtils;
import com.microservices.common.core.utils.StringUtils;
import com.microservices.common.httpClient.util.GitLinkRequestHelper;
import com.microservices.common.security.utils.SecurityUtils;
import com.microservices.pms.common.service.IPmsCommonService;
@ -17,6 +18,8 @@ import com.microservices.pms.product.service.IPmsProductRequirementService;
import com.microservices.pms.project.domain.PmsProject;
import com.microservices.pms.project.domain.SimpleRepository;
import com.microservices.pms.project.domain.vo.*;
import com.microservices.pms.project.mapper.PmsProjectSprintMapper;
import com.microservices.pms.project.mapper.PmsProjectTestsheetMapper;
import com.microservices.pms.utils.PmsConstants;
import com.microservices.pms.utils.PmsGitLinkRequestUrl;
import com.microservices.pms.utils.PmsUtils;
@ -31,6 +34,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.net.URISyntaxException;
import java.util.*;
@ -72,6 +76,10 @@ public class PmsProjectIssuesService {
@Autowired
private IPmsCommonService pmsCommonService;
@Resource
private PmsProjectSprintMapper pmsProjectSprintMapper;
@Resource
private PmsProjectTestsheetMapper pmsProjectTestsheetMapper;
public JSONObject selectPmsProjectIssuesList(PmsProjectIssuesSearchVo pmsProjectIssuesSearchVo) {
@ -574,4 +582,52 @@ public class PmsProjectIssuesService {
throw new RuntimeException(e);
}
}
public JSONObject getPersonalIssuesStatistics(String enterpriseIdentifier) {
Long gitlinkUserId = SecurityUtils.getGitlinkUserId();
return gitLinkRequestHelper.doGet(PmsGitLinkRequestUrl.GET_WEEKLY_ISSUES_PERSONAL(enterpriseIdentifier, gitlinkUserId));
}
public JSONObject getProjectTeamIssuesStatistics(String enterpriseIdentifier) {
List<Long> pmProjectIds = pmsProjectService.selectProjectIdsByAssigneeUserId(enterpriseIdentifier, SecurityUtils.getGitlinkUserId());
String pmProjectIdsStr = StringUtils.join(pmProjectIds, ",");
JSONObject result = gitLinkRequestHelper.doGet(PmsGitLinkRequestUrl.GET_WEEKLY_ISSUES_GROUP(enterpriseIdentifier, pmProjectIdsStr));
enrichProjectInfo(result);
return result;
}
public void enrichProjectInfo(JSONObject inputJson) {
// 遍历最外层 key
for (String projectIdStr : inputJson.keySet()) {
Long projectId = Long.valueOf(projectIdStr); // 转换为 Long
// 查询项目信息
PmsProjectDetailVo project = pmsProjectService.selectPmsProjectById(projectId);
if (project != null) {
// 将项目信息转换为 JSONObject
JSONObject projectInfo = new JSONObject();
projectInfo.put("projectId", project.getId());
projectInfo.put("projectName", project.getProjectName());
projectInfo.put("enterpriseId", project.getPmsEnterpriseId());
projectInfo.put("createdTime", project.getCreateTime());
// projectInfo 插入到原 JSON 的对应层级中
JSONObject innerData = inputJson.getJSONObject(projectIdStr);
innerData.put("project_info", projectInfo);
}
// 统计新建迭代数
inputJson.put("this_week_new_sprint_count", pmsProjectSprintMapper.selectNewSprintCurrentNaturalWeekCount(projectId));
// 统计完成迭代数
inputJson.put("this_week_complete_sprint_count", pmsProjectSprintMapper.selectCompleteSprintCurrentNaturalWeekCount(projectId));
// 统计新建测试单数
inputJson.put("this_week_new_test_sheet_count", pmsProjectTestsheetMapper.selectNewTestSheetCurrentNaturalWeekCount(projectId));
// 统计完成测试单数
inputJson.put("this_week_complete_test_sheet_count", pmsProjectTestsheetMapper.selectCompleteTestSheetCurrentNaturalWeekCount(projectId));
}
}
}

View File

@ -396,6 +396,11 @@ public class PmsProjectServiceImpl implements IPmsProjectService {
return pmsProject;
}
@Override
public List<Long> selectProjectIdsByAssigneeUserId(String enterpriseIdentifier, Long gitlinkUserId) {
return pmsProjectMapper.selectProjectIdsByAssigneeUserId(enterpriseIdentifier, gitlinkUserId);
}
@Override
public PmsProject selectAndCheckPmsProjectById(String idStr) {
if (StringUtils.isEmpty(idStr)) {

View File

@ -439,4 +439,14 @@ public class PmsGitLinkRequestUrl extends GitLinkRequestUrl {
public static GitLinkRequestUrl GET_ACTION_RUN_DATA(String owner, String workflows) {
return getGitLinkRequestUrl(String.format("/api/pm/action_runs?owner_id=%s&workflows=%s", owner, workflows), "data");
}
public static GitLinkRequestUrl GET_WEEKLY_ISSUES_PERSONAL(String enterpriseIdentifier, Long gitlinkUserId){
return getGitLinkRequestUrl(
String.format("/api/pm/weekly_issues/personal.json?enterprise_identifier=%s&user_id=%s", enterpriseIdentifier, gitlinkUserId));
}
public static GitLinkRequestUrl GET_WEEKLY_ISSUES_GROUP(String enterpriseIdentifier, String pmProjectIds){
return getGitLinkRequestUrl(
String.format("/api/pm/weekly_issues/group.json?enterprise_identifier=%s&pm_project_ids=%s", enterpriseIdentifier, pmProjectIds));
}
}

View File

@ -173,6 +173,13 @@
from pms_project
<include refid="selectWhereBySearchVo"/>
</select>
<select id="selectProjectIdsByAssigneeUserId" resultType="java.lang.Long">
select pp.id
from pms_project pp
left join pms_enterprise pe on pe.id = pp.pms_enterprise_id
where pp.project_assignee_id = #{gitlinkUserId}
and pe.enterprise_identifier = #{enterpriseIdentifier}
</select>
<insert id="insertPmsProject" parameterType="PmsProject" useGeneratedKeys="true" keyProperty="id">
insert into pms_project

View File

@ -221,4 +221,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
WHERE pms_project_id = #{pmProjectId} AND status = 2
) AS `closed_sprint_count`
</select>
<select id="selectNewSprintCurrentNaturalWeekCount" resultType="java.lang.Integer">
select count(*)
from pms_project_sprint
where pms_project_id = #{projectId}
AND create_time <![CDATA[ >= ]]> STR_TO_DATE(DATE_FORMAT(NOW(), '%Y-%V-1'), '%Y-%U-%w')
AND create_time <![CDATA[ <= ]]> STR_TO_DATE(DATE_FORMAT(NOW(), '%Y-%V-1'), '%Y-%U-%w') + INTERVAL 6 DAY
</select>
<select id="selectCompleteSprintCurrentNaturalWeekCount" resultType="java.lang.Integer">
select count(*)
from pms_project_sprint
where pms_project_id = #{projectId}
AND status = 2
AND update_time <![CDATA[ >= ]]> STR_TO_DATE(DATE_FORMAT(NOW(), '%Y-%V-1'), '%Y-%U-%w')
AND update_time <![CDATA[ <= ]]> STR_TO_DATE(DATE_FORMAT(NOW(), '%Y-%V-1'), '%Y-%U-%w') + INTERVAL 6 DAY
</select>
</mapper>

View File

@ -53,6 +53,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectCountBySprintId" resultType="java.lang.Integer">
select count(*) from pms_project_testsheet where project_sprint_id = #{sprintId}
</select>
<select id="selectNewTestSheetCurrentNaturalWeekCount" resultType="java.lang.Integer">
select count(*)
from pms_project_testsheet
where pms_project_id = #{projectId}
AND create_time <![CDATA[ >= ]]> STR_TO_DATE(DATE_FORMAT(NOW(), '%Y-%V-1'), '%Y-%U-%w')
AND create_time <![CDATA[ <= ]]> STR_TO_DATE(DATE_FORMAT(NOW(), '%Y-%V-1'), '%Y-%U-%w') + INTERVAL 6 DAY
</select>
<select id="selectCompleteTestSheetCurrentNaturalWeekCount" resultType="java.lang.Integer">
select count(*)
from pms_project_testsheet
where pms_project_id = #{projectId}
AND status = 2
AND update_time <![CDATA[ >= ]]> STR_TO_DATE(DATE_FORMAT(NOW(), '%Y-%V-1'), '%Y-%U-%w')
AND update_time <![CDATA[ <= ]]> STR_TO_DATE(DATE_FORMAT(NOW(), '%Y-%V-1'), '%Y-%U-%w') + INTERVAL 6 DAY
</select>
<insert id="insertPmsProjectTestsheet" parameterType="PmsProjectTestsheet" useGeneratedKeys="true" keyProperty="id">
insert into pms_project_testsheet