Merge branch 'dev_weeklyReport_refact' into dev_weeklyReport_wikiPrevision_merge

This commit is contained in:
wanjia 2025-05-27 17:28:00 +08:00
commit 79136717ef
18 changed files with 423 additions and 17 deletions

View File

@ -32,6 +32,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@ -172,6 +173,12 @@ public class PmsDashboardController extends BaseController {
}
todoProjectIssuesSearchVo.setPmProjectIds(StringUtils.join(projectList.stream().map(PmsProject::getId).toArray(), ","));
JSONObject result = pmsProjectIssuesService.selectMyTodoPmsProjectIssuesList(todoProjectIssuesSearchVo);
// 判断projectList中是否存在projectAssigneeId和当前用户id相等
Long currentUserId = SecurityUtils.getGitlinkUserId();
boolean isProjectAssigner = projectList.stream()
.anyMatch(project -> currentUserId != null && currentUserId.equals(project.getProjectAssigneeId()));
result.put("isProjectAssigner", isProjectAssigner);
return success(result);
}

View File

@ -44,7 +44,8 @@ public class PmsProjectIssuesController extends BaseController {
@RequiresPermissions(value = {"pms:pmsProject:show", "pms:pmsProject:showMe", "pms:pmsProjectTestsheet:edit"}, logical = Logical.OR)
@GetMapping("/list")
@ApiOperation(value = "项目工作项列表")
public AjaxResult list(PmsProjectIssuesSearchVo pmsProjectIssuesSearchVo) {
public AjaxResult list(@PathVariable String enterpriseIdentifier, PmsProjectIssuesSearchVo pmsProjectIssuesSearchVo) {
pmsProjectIssuesSearchVo.setEnterpriseIdentifier(enterpriseIdentifier);
JSONObject result = pmsProjectIssuesService.selectPmsProjectIssuesList(pmsProjectIssuesSearchVo);
return success(result);
}

View File

@ -2,6 +2,8 @@ package com.microservices.pms.project.controller;
import com.alibaba.fastjson2.JSONObject;
import com.microservices.common.core.web.domain.AjaxResult;
import com.microservices.pms.project.domain.vo.PmsPersonalWeeklyIssuesSearchVo;
import com.microservices.pms.project.domain.vo.PmsPersonalWeeklyReportSearchVo;
import com.microservices.pms.project.domain.vo.PmsProjectIssuesInputVo;
import com.microservices.pms.project.domain.vo.PmsProjectIssuesSearchVo;
import com.microservices.pms.project.service.PmsProjectIssuesService;
@ -35,20 +37,62 @@ public class PmsProjectWeeklyReportController {
*/
@GetMapping("/list")
@ApiOperation(value = "项目周报列表")
public AjaxResult list(PmsProjectIssuesSearchVo pmsProjectIssuesSearchVo)
public AjaxResult list(@PathVariable String enterpriseIdentifier, PmsProjectIssuesSearchVo pmsProjectIssuesSearchVo)
{
pmsProjectIssuesSearchVo.setEnterpriseIdentifier(enterpriseIdentifier);
JSONObject result = pmsProjectIssuesService.selectPmsProjectIssuesList(pmsProjectIssuesSearchVo);
return success(result);
}
/**
* 查询周报-个人工作项统计
*/
@GetMapping("/personal")
@ApiOperation(value = "周报-个人工作项统计")
public AjaxResult getPersonalWeeklyReport(@PathVariable String enterpriseIdentifier, PmsPersonalWeeklyReportSearchVo pmsPersonalWeeklyReportSearchVo)
{
JSONObject result = pmsProjectIssuesService.getPersonalIssuesStatistics(enterpriseIdentifier, pmsPersonalWeeklyReportSearchVo);
return success(result);
}
@GetMapping("/personalIssueList")
@ApiOperation(value = "周报-个人工作项列表")
public AjaxResult getPersonalIssueList(@PathVariable String enterpriseIdentifier, PmsPersonalWeeklyIssuesSearchVo pmsPersonalWeeklyIssuesSearchVo)
{
pmsPersonalWeeklyIssuesSearchVo.setEnterpriseIdentifier(enterpriseIdentifier);
JSONObject result = pmsProjectIssuesService.getPersonalIssueList(pmsPersonalWeeklyIssuesSearchVo);
return success(result);
}
/**
* 查询周报-项目组工作项统计
*/
@GetMapping("/projectTeam")
@ApiOperation(value = "周报-项目组工作项统计")
public AjaxResult getProjectTeamWeeklyReport(@PathVariable String enterpriseIdentifier)
{
JSONObject result = pmsProjectIssuesService.getProjectTeamIssuesStatistics(enterpriseIdentifier);
return success(result);
}
@GetMapping("/projectIssueList")
@ApiOperation(value = "周报-项目组工作项列表")
public AjaxResult getProjectIssueList(@PathVariable String enterpriseIdentifier, PmsProjectIssuesSearchVo pmsProjectIssuesSearchVo)
{
pmsProjectIssuesSearchVo.setEnterpriseIdentifier(enterpriseIdentifier);
JSONObject result = pmsProjectIssuesService.getProjectIssueList(pmsProjectIssuesSearchVo);
return success(result);
}
/**
* 新增项目项目周报
*/
@PostMapping("/add")
@ApiOperation(value = "新增项目周报")
public AjaxResult add(@RequestBody PmsProjectIssuesInputVo pmsProjectIssuesInputVo)
public AjaxResult add(@PathVariable String enterpriseIdentifier, @RequestBody PmsProjectIssuesInputVo pmsProjectIssuesInputVo)
{
JSONObject result = pmsProjectIssuesService.insertPmsProjectIssues(pmsProjectIssuesInputVo);
pmsProjectIssuesInputVo.setEnterpriseIdentifier(enterpriseIdentifier);
JSONObject result = pmsProjectIssuesService.insertPmsProjectWeeklyReportIssues(pmsProjectIssuesInputVo);
return success(result);
}
@ -59,18 +103,18 @@ public class PmsProjectWeeklyReportController {
@ApiOperation(value = "编辑项目周报")
public AjaxResult edit(@PathVariable("id") Long id, @RequestBody PmsProjectIssuesInputVo pmsProjectIssuesInputVo)
{
JSONObject result = pmsProjectIssuesService.updatePmsProjectIssues(id, pmsProjectIssuesInputVo);
JSONObject result = pmsProjectIssuesService.updatePmsProjectWeeklyReportIssues(id, pmsProjectIssuesInputVo);
return success(result);
}
/**
* 删除项目周报
*/
@DeleteMapping("/{ids}")
public AjaxResult remove(@ApiParam( "周报id数组,为-1时删除全部")@PathVariable Long[] ids, @ApiParam( "项目Id")@RequestParam(name = "pmProjectId") Long pmProjectId)
@DeleteMapping("/{id}")
public AjaxResult remove(@ApiParam( "周报id")@PathVariable Long id)
{
JSONObject result = pmsProjectIssuesService.deletePmsProjectIssueByIds(ids, pmProjectId);
JSONObject result = pmsProjectIssuesService.deletePmsProjectWeeklyReportIssueByIds(id);
return success(result);
}
@ -78,10 +122,10 @@ public class PmsProjectWeeklyReportController {
* 查看项目周报
*/
@GetMapping("/{id}")
public AjaxResult query(@PathVariable("id") Long id, @ApiParam( "项目Id")@RequestParam(name = "pmProjectId") Long pmProjectId)
public AjaxResult query(@PathVariable String enterpriseIdentifier, @PathVariable("id") Long id)
{
JSONObject result = pmsProjectIssuesService.selectPmsProjectIssueById(id, pmProjectId);
JSONObject result = pmsProjectIssuesService.selectPmsProjectIssueByIdAndEnterPrise(id, enterpriseIdentifier);
return success(result);
}
}

View File

@ -0,0 +1,46 @@
package com.microservices.pms.project.domain.vo;
import com.microservices.common.core.utils.ServletUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data
@ApiModel("个人周报工作项搜索对象")
public class PmsPersonalWeeklyIssuesSearchVo {
@ApiModelProperty(value = "用户gitlink用户id")
private Long userId;
@ApiModelProperty(value = "企业标识", hidden = true)
private String enterpriseIdentifier;
@ApiModelProperty(value = "工作项名称搜索关键词")
private String keyword;
@ApiModelProperty(value = "状态值,可多个状态逗号隔开")
private String statusIds;
@ApiModelProperty(value = "排序方式: issues.updated_on 更新时间 issues.created_on 创建时间 issue_priorities.position 优先级")
private String sortBy;
@ApiModelProperty(value = "排序方向:asc 正序 desc 倒序")
private String sortDirection;
@ApiModelProperty(value = "本周工作项页码")
private String thisWeekPage;
@ApiModelProperty(value = "分页数")
private String thisWeekLimit;
@ApiModelProperty(value = "本周工作项页码")
private String nextWeekPage;
@ApiModelProperty(value = "分页数")
private String nextWeekLimit;
public void setKeyword(String keyword) {
this.keyword = ServletUtils.urlDecode(keyword);
}
}

View File

@ -0,0 +1,17 @@
package com.microservices.pms.project.domain.vo;
import com.microservices.common.core.utils.ServletUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel("个人周报工作项统计对象")
public class PmsPersonalWeeklyReportSearchVo {
@ApiModelProperty(value = "用户gitlink用户id", hidden = true)
private Long userId;
@ApiModelProperty(value = "企业标识", hidden = true)
private String enterpriseIdentifier;
}

View File

@ -9,7 +9,10 @@ import lombok.Data;
@ApiModel("项目工作项搜索对象")
public class PmsProjectIssuesSearchVo {
@ApiModelProperty(value = "项目id", required = true)
@ApiModelProperty(value = "企业标识", hidden = true)
private String enterpriseIdentifier;
@ApiModelProperty(value = "项目id")
private String pmProjectId;
@ApiModelProperty(value = "项目迭代id")

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,9 @@ 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.PmsProjectMapper;
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 +35,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 +77,12 @@ public class PmsProjectIssuesService {
@Autowired
private IPmsCommonService pmsCommonService;
@Resource
private PmsProjectSprintMapper pmsProjectSprintMapper;
@Resource
private PmsProjectTestsheetMapper pmsProjectTestsheetMapper;
@Resource
private PmsProjectMapper pmsProjectMapper;
public JSONObject selectPmsProjectIssuesList(PmsProjectIssuesSearchVo pmsProjectIssuesSearchVo) {
@ -92,6 +103,7 @@ public class PmsProjectIssuesService {
for (int i = 0; i < issues.size(); i++) {
JSONObject issue = issues.getJSONObject(i);
setIssueAssignersState(issue, gitlinkUserNickNameMap);
setIssuePmsProjectName(issue);
issues.set(i, issue);
}
issueListResult.put("issues", issues);
@ -99,6 +111,60 @@ public class PmsProjectIssuesService {
return issueListResult;
}
public JSONObject enrichProjectIssueList(JSONObject issueListResult) {
HashMap<Long, String> gitlinkUserNickNameMap = new HashMap<>();
if (issueListResult.containsKey("this_week_all_issues")) {
JSONArray issues = issueListResult.getJSONArray("this_week_all_issues");
if (issues != null) {
for (int i = 0; i < issues.size(); i++) {
JSONObject issue = issues.getJSONObject(i);
setIssueAssignersState(issue, gitlinkUserNickNameMap);
setIssuePmsProjectName(issue);
issues.set(i, issue);
}
issueListResult.put("this_week_all_issues", issues);
}
}
if (issueListResult.containsKey("next_week_all_issues")) {
JSONArray issues = issueListResult.getJSONArray("next_week_all_issues");
if (issues != null) {
for (int i = 0; i < issues.size(); i++) {
JSONObject issue = issues.getJSONObject(i);
setIssueAssignersState(issue, gitlinkUserNickNameMap);
setIssuePmsProjectName(issue);
issues.set(i, issue);
}
issueListResult.put("next_week_all_issues", issues);
}
}
if (issueListResult.containsKey("close_task_issues")) {
JSONArray issues = issueListResult.getJSONArray("close_task_issues");
if (issues != null) {
for (int i = 0; i < issues.size(); i++) {
JSONObject issue = issues.getJSONObject(i);
setIssueAssignersState(issue, gitlinkUserNickNameMap);
setIssuePmsProjectName(issue);
issues.set(i, issue);
}
issueListResult.put("close_task_issues", issues);
}
}
return issueListResult;
}
private void setIssuePmsProjectName(JSONObject issue) {
if (issue.containsKey("pm_project_id")) {
Long pmProjectId = issue.getLong("pm_project_id");
if (pmProjectId == null) {
return;
}
PmsProject pmsProject = pmsProjectMapper.selectPmsProjectById(pmProjectId);
if (pmsProject != null) {
issue.put("pm_project_name", pmsProject.getProjectName());
}
}
}
public JSONObject insertPmsProjectIssuesRestricted(PmsProjectIssuesInputVo pmsProjectIssuesInputVo) {
PmsProject pmsProject = pmsProjectService.selectAndCheckPmsProjectById(pmsProjectIssuesInputVo.getPmProjectId());
if (pmsProject.getPmsProductId() != null
@ -115,6 +181,11 @@ public class PmsProjectIssuesService {
return gitLinkRequestHelper.doPost(PmsGitLinkRequestUrl.CREATE_ISSUE(), issueInput);
}
public JSONObject insertPmsProjectWeeklyReportIssues(PmsProjectIssuesInputVo pmsProjectIssuesInputVo) {
JSONObject issueInput = convertPmsProjectIssuesInputVoToIssueInputJSON(pmsProjectIssuesInputVo);
return gitLinkRequestHelper.doPost(PmsGitLinkRequestUrl.CREATE_ISSUE(), issueInput);
}
@Transactional(rollbackFor = Exception.class)
public JSONObject updatePmsProjectIssues(Long id, PmsProjectIssuesInputVo pmsProjectIssuesInputVo) {
PmsProject pmsProject = pmsProjectService.selectAndCheckPmsProjectById(pmsProjectIssuesInputVo.getPmProjectId());
@ -152,7 +223,7 @@ public class PmsProjectIssuesService {
}
}
}
if (PmsConstants.PROJECT_ISSUE_TYPE_WEEKLY_REPORT.equals(updatedIssue.getString("pm_issue_type"))
if (PmsConstants.PROJECT_ISSUE_TYPE_PERSONAL_WEEKLY_REPORT.equals(updatedIssue.getString("pm_issue_type"))
&& updatedIssue.getString("root_id") != null
&& !updatedIssue.getJSONObject("author").getLong("id").equals(SecurityUtils.getGitlinkUserId())) {
throw new ServiceException("非本人周报,不可编辑");
@ -161,6 +232,27 @@ public class PmsProjectIssuesService {
return gitLinkRequestHelper.doPut(PmsGitLinkRequestUrl.UPDATE_ISSUE(id), issueInput);
}
public JSONObject updatePmsProjectWeeklyReportIssues(Long id, PmsProjectIssuesInputVo pmsProjectIssuesInputVo) {
JSONObject updatedIssue;
try {
updatedIssue = gitLinkRequestHelper.doGet(PmsGitLinkRequestUrl.GET_ISSUE(id, null));
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
isIssueCreatedByCurrentUser(updatedIssue);
JSONObject issueInput = convertPmsProjectIssuesInputVoToIssueInputJSON(pmsProjectIssuesInputVo);
return gitLinkRequestHelper.doPut(PmsGitLinkRequestUrl.UPDATE_ISSUE(id), issueInput);
}
private static void isIssueCreatedByCurrentUser(JSONObject updatedIssue) {
if ((PmsConstants.PROJECT_ISSUE_TYPE_PERSONAL_WEEKLY_REPORT.equals(updatedIssue.getString("pm_issue_type"))
|| PmsConstants.PROJECT_ISSUE_TYPE_GROUP_WEEKLY_REPORT.equals(updatedIssue.getString("pm_issue_type")))
&& updatedIssue.getString("root_id") != null
&& !updatedIssue.getJSONObject("author").getLong("id").equals(SecurityUtils.getGitlinkUserId())) {
throw new ServiceException("非本人周报,不可编辑");
}
}
public JSONObject batchUpdatePmsProjectIssues(Long pmProjectId, PmsProjectIssuesBatchUpdateVo pmsProjectIssuesUpdateVo) {
pmsProjectService.selectAndCheckPmsProjectById(pmProjectId);
//转换为issue入参
@ -180,6 +272,17 @@ public class PmsProjectIssuesService {
}
}
public JSONObject selectPmsProjectIssueByIdAndEnterPrise(Long id, String enterpriseIdentifier) {
PmsEnterprise pmsEnterprise = pmsEnterpriseService.selectPmsEnterpriseByIdentifier(enterpriseIdentifier);
try {
JSONObject result = setProjectIssueUserState(gitLinkRequestHelper.doGet(PmsGitLinkRequestUrl.GET_ISSUE(id, null)));
result.put("pm_enterprise_name", pmsEnterprise.getEnterpriseName());
return result;
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}
public JSONObject selectPmsProjectIssueByIdNoCheckRole(Long id, Long pmProjectId) {
PmsProject pmsProject = pmsProjectService.selectPmsProjectByIdNoCheckRole(pmProjectId);
try {
@ -309,6 +412,17 @@ public class PmsProjectIssuesService {
return gitLinkRequestHelper.doDelete(PmsGitLinkRequestUrl.DELETE_ISSUES_BATCH(pmProjectId), jsonObject);
}
public JSONObject deletePmsProjectWeeklyReportIssueByIds(Long id) {
JSONObject updatedIssue;
try {
updatedIssue = gitLinkRequestHelper.doGet(PmsGitLinkRequestUrl.GET_ISSUE(id, null));
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
isIssueCreatedByCurrentUser(updatedIssue);
return gitLinkRequestHelper.doDelete(PmsGitLinkRequestUrl.DELETE_WEEKLY_REPORT_ISSUE(id));
}
public JSONObject selectPmsProjectIssueStatus() {
return gitLinkRequestHelper.doGet(PmsGitLinkRequestUrl.GET_REPO_ISSUE_DEFAULT_STATUS());
}
@ -574,4 +688,92 @@ public class PmsProjectIssuesService {
throw new RuntimeException(e);
}
}
public JSONObject getPersonalIssuesStatistics(String enterpriseIdentifier, PmsPersonalWeeklyReportSearchVo pmsPersonalWeeklyReportSearchVo) {
Long gitlinkUserId = SecurityUtils.getGitlinkUserId();
pmsPersonalWeeklyReportSearchVo.setUserId(gitlinkUserId);
pmsPersonalWeeklyReportSearchVo.setEnterpriseIdentifier(enterpriseIdentifier);
JSONObject issueSearch = new JSONObject();
convertObjectToJSONObject(pmsPersonalWeeklyReportSearchVo, issueSearch, null);
try {
return enrichProjectIssueList(gitLinkRequestHelper.doGet(PmsGitLinkRequestUrl.GET_WEEKLY_ISSUES_PERSONAL(issueSearch)));
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}
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) {
if (inputJson == null) {
return;
}
// 遍历最外层 key
for (String projectIdStr : inputJson.keySet()) {
Long projectId;
try {
projectId = Long.valueOf(projectIdStr); // 转换为 Long
} catch (NumberFormatException e) {
// 非数字字符串跳过处理
continue;
}
// 查询项目信息
PmsProject project = pmsProjectMapper.selectPmsProjectById(projectId);
JSONObject innerData = inputJson.getJSONObject(projectIdStr);
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 的对应层级中
innerData.put("project_info", projectInfo);
}
// 统计新建迭代数
innerData.put("this_week_new_sprint_count", pmsProjectSprintMapper.selectNewSprintCurrentNaturalWeekCount(projectId));
// 统计完成迭代数
innerData.put("this_week_complete_sprint_count", pmsProjectSprintMapper.selectCompleteSprintCurrentNaturalWeekCount(projectId));
// 统计新建测试单数
innerData.put("this_week_new_test_sheet_count", pmsProjectTestsheetMapper.selectNewTestSheetCurrentNaturalWeekCount(projectId));
// 统计完成测试单数
innerData.put("this_week_complete_test_sheet_count", pmsProjectTestsheetMapper.selectCompleteTestSheetCurrentNaturalWeekCount(projectId));
}
}
public JSONObject getProjectIssueList(PmsProjectIssuesSearchVo pmsProjectIssuesSearchVo) {
List<Long> pmProjectIds = pmsProjectService.selectProjectIdsByAssigneeUserId(
pmsProjectIssuesSearchVo.getEnterpriseIdentifier(),
StringUtils.isEmpty(pmsProjectIssuesSearchVo.getAssignerId()) ? SecurityUtils.getGitlinkUserId() : Long.valueOf(pmsProjectIssuesSearchVo.getAssignerId()));
String pmProjectIdsStr = StringUtils.join(pmProjectIds, ",");
pmsProjectIssuesSearchVo.setPmProjectIds(pmProjectIdsStr);
JSONObject issueSearch = new JSONObject();
convertObjectToJSONObject(pmsProjectIssuesSearchVo, issueSearch, null);
try {
return setProjectIssueListUserState(gitLinkRequestHelper.doGet(PmsGitLinkRequestUrl.GET_GROUP_ISSUE_LIST(issueSearch)));
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}
public JSONObject getPersonalIssueList(PmsPersonalWeeklyIssuesSearchVo pmsPersonalWeeklyIssuesSearchVo) {
pmsPersonalWeeklyIssuesSearchVo.setUserId(pmsPersonalWeeklyIssuesSearchVo.getUserId() == null ? SecurityUtils.getGitlinkUserId() : pmsPersonalWeeklyIssuesSearchVo.getUserId());
JSONObject issueSearch = new JSONObject();
convertObjectToJSONObject(pmsPersonalWeeklyIssuesSearchVo, issueSearch, null);
try {
return enrichProjectIssueList(gitLinkRequestHelper.doGet(PmsGitLinkRequestUrl.GET_PERSONAL_ISSUE_LIST(issueSearch)));
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}
}

View File

@ -127,7 +127,6 @@ public class PmsProjectRepositoryServiceImpl implements IPmsProjectRepositorySer
*/
@Override
public int insertPmsProjectRepository(PmsProjectRepository pmsProjectRepository) {
pmsProjectService.selectAndCheckPmsProjectById(pmsProjectRepository.getPmsProjectId());
//仓库已被关联返回错误提示
if (pmsProjectRepositoryMapper.countPmsProjectRepositoryByProjectRepositoryId(pmsProjectRepository.getProjectRepositoryId()) > 0) {
throw new ServiceException("代码库id:[%s]已被关联", pmsProjectRepository.getProjectRepositoryId());

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

@ -122,9 +122,14 @@ public class PmsConstants {
public final static String PROJECT_ISSUE_TYPE_BUG = "3";
/**
* 项目工作项周报类型
* 项目工作项个人周报类型
*/
public final static String PROJECT_ISSUE_TYPE_WEEKLY_REPORT = "4";
public final static String PROJECT_ISSUE_TYPE_PERSONAL_WEEKLY_REPORT = "4";
/**
* 项目工作项项目组周报类型
*/
public final static String PROJECT_ISSUE_TYPE_GROUP_WEEKLY_REPORT = "5";
/**
* 疑修筛选类型-全部

View File

@ -146,7 +146,9 @@ public class PmsGitLinkRequestUrl extends GitLinkRequestUrl {
public static GitLinkRequestUrl GET_ISSUE(Long id, Long pmProjectId) throws URISyntaxException {
Map<String, String> params = new HashMap<>();
params.put("pm_project_id", String.valueOf(pmProjectId));
if (pmProjectId != null) {
params.put("pm_project_id", String.valueOf(pmProjectId));
}
return getGitLinkRequestUrl(buildUri(String.format(
"/api/pm/issues/%s", id), params
));
@ -164,6 +166,12 @@ public class PmsGitLinkRequestUrl extends GitLinkRequestUrl {
));
}
public static GitLinkRequestUrl DELETE_WEEKLY_REPORT_ISSUE(Long id) {
return getGitLinkRequestUrl(String.format(
"/api/pm/issues/%s", id
));
}
public static GitLinkRequestUrl DELETE_ISSUES_BATCH(Long pmProjectId) {
String path = String.format("/api/pm/issues/batch_destroy?pm_project_id=%s", pmProjectId);
return getGitLinkRequestUrl(path);
@ -439,4 +447,25 @@ 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(JSONObject issueSearch) throws URISyntaxException {
return getGitLinkRequestUrl(
buildUri("/api/pm/weekly_issues/personal.json", issueSearch));
}
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));
}
public static GitLinkRequestUrl GET_GROUP_ISSUE_LIST(JSONObject params) throws URISyntaxException {
return getGitLinkRequestUrl(
buildUri("/api/pm/weekly_issues/group_issues.json", params));
}
public static GitLinkRequestUrl GET_PERSONAL_ISSUE_LIST(JSONObject issueSearch) throws URISyntaxException {
return getGitLinkRequestUrl(
buildUri("/api/pm/weekly_issues/personal_issues.json", issueSearch));
}
}

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