feat(周报功能重构):周报操作去除项目编号绑定

This commit is contained in:
wanjia 2025-05-22 14:17:28 +08:00
parent 3c2b288068
commit fe7c642a08
4 changed files with 72 additions and 13 deletions

View File

@ -72,7 +72,7 @@ public class PmsProjectWeeklyReportController {
public AjaxResult add(@PathVariable String enterpriseIdentifier, @RequestBody PmsProjectIssuesInputVo pmsProjectIssuesInputVo)
{
pmsProjectIssuesInputVo.setEnterpriseIdentifier(enterpriseIdentifier);
JSONObject result = pmsProjectIssuesService.insertPmsProjectIssues(pmsProjectIssuesInputVo);
JSONObject result = pmsProjectIssuesService.insertPmsProjectWeeklyReportIssues(pmsProjectIssuesInputVo);
return success(result);
}
@ -83,18 +83,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);
}
@ -102,10 +102,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

@ -123,6 +123,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());
@ -160,7 +165,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("非本人周报,不可编辑");
@ -169,6 +174,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入参
@ -188,6 +214,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 {
@ -317,6 +354,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());
}
@ -628,6 +676,4 @@ public class PmsProjectIssuesService {
inputJson.put("this_week_complete_test_sheet_count", pmsProjectTestsheetMapper.selectCompleteTestSheetCurrentNaturalWeekCount(projectId));
}
}
}

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<>();
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);