未验证 提交 90a9a728 编写于 作者: W wen-hemin 提交者: GitHub

[Fix-5518]: The user definition count interface, projectId change to projectCode (#5839)

* fix: the data analysis state count interface, projectId change to projectCode

* fix: the data analysis state count interface, projectId change to projectCode

* fix checkstyle

* fix checkstyle

* fix: the process state count page use "projectCode"

* fix: English comments

* fix: the user definition count interface, projectId change to projectCode

* fix comment
Co-authored-by: Nwen-hemin <wenhemin@apache.com>
上级 5f5aec93
...@@ -118,21 +118,21 @@ public class DataAnalysisController extends BaseController { ...@@ -118,21 +118,21 @@ public class DataAnalysisController extends BaseController {
* statistics the process definition quantities of certain person * statistics the process definition quantities of certain person
* *
* @param loginUser login user * @param loginUser login user
* @param projectId project id * @param projectCode project code
* @return definition count in project id * @return definition count in project code
*/ */
@ApiOperation(value = "countDefinitionByUser", notes = "COUNT_PROCESS_DEFINITION_BY_USER_NOTES") @ApiOperation(value = "countDefinitionByUser", notes = "COUNT_PROCESS_DEFINITION_BY_USER_NOTES")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "projectId", value = "PROJECT_ID", dataType = "Int", example = "100") @ApiImplicitParam(name = "projectCode", value = "PROJECT_CODE", dataType = "Long", example = "100")
}) })
@GetMapping(value = "/define-user-count") @GetMapping(value = "/define-user-count")
@ResponseStatus(HttpStatus.OK) @ResponseStatus(HttpStatus.OK)
@ApiException(COUNT_PROCESS_DEFINITION_USER_ERROR) @ApiException(COUNT_PROCESS_DEFINITION_USER_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser") @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result countDefinitionByUser(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, public Result countDefinitionByUser(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam(value = "projectId", required = false, defaultValue = "0") int projectId) { @RequestParam(value = "projectCode", required = false, defaultValue = "0") long projectCode) {
Map<String, Object> result = dataAnalysisService.countDefinitionByUser(loginUser, projectId); Map<String, Object> result = dataAnalysisService.countDefinitionByUser(loginUser, projectCode);
return returnDataList(result); return returnDataList(result);
} }
......
...@@ -52,10 +52,10 @@ public interface DataAnalysisService { ...@@ -52,10 +52,10 @@ public interface DataAnalysisService {
* statistics the process definition quantities of certain person * statistics the process definition quantities of certain person
* *
* @param loginUser login user * @param loginUser login user
* @param projectId project id * @param projectCode project code
* @return definition count data * @return definition count data
*/ */
Map<String, Object> countDefinitionByUser(User loginUser, int projectId); Map<String, Object> countDefinitionByUser(User loginUser, long projectCode);
/** /**
* statistical command status data * statistical command status data
......
...@@ -132,11 +132,15 @@ public class DataAnalysisServiceImpl extends BaseServiceImpl implements DataAnal ...@@ -132,11 +132,15 @@ public class DataAnalysisServiceImpl extends BaseServiceImpl implements DataAnal
private Map<String, Object> countStateByProject(User loginUser, long projectCode, String startDate, String endDate private Map<String, Object> countStateByProject(User loginUser, long projectCode, String startDate, String endDate
, TriFunction<Date, Date, Long[], List<ExecuteStatusCount>> instanceStateCounter) { , TriFunction<Date, Date, Long[], List<ExecuteStatusCount>> instanceStateCounter) {
Map<String, Object> result = new HashMap<>();
if (projectCode != 0) {
Project project = projectMapper.queryByCode(projectCode); Project project = projectMapper.queryByCode(projectCode);
Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, project.getName()); result = projectService.checkProjectAndAuth(loginUser, project, project.getName());
if (result.get(Constants.STATUS) != Status.SUCCESS) { if (result.get(Constants.STATUS) != Status.SUCCESS) {
return result; return result;
} }
}
Date start = null; Date start = null;
Date end = null; Date end = null;
...@@ -167,18 +171,23 @@ public class DataAnalysisServiceImpl extends BaseServiceImpl implements DataAnal ...@@ -167,18 +171,23 @@ public class DataAnalysisServiceImpl extends BaseServiceImpl implements DataAnal
* statistics the process definition quantities of certain person * statistics the process definition quantities of certain person
* *
* @param loginUser login user * @param loginUser login user
* @param projectId project id * @param projectCode project code
* @return definition count data * @return definition count data
*/ */
@Override @Override
public Map<String, Object> countDefinitionByUser(User loginUser, int projectId) { public Map<String, Object> countDefinitionByUser(User loginUser, long projectCode) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
boolean checkProject = checkProject(loginUser, projectId, result);
if (!checkProject) { if (projectCode != 0) {
Project project = projectMapper.queryByCode(projectCode);
result = projectService.checkProjectAndAuth(loginUser, project, project.getName());
if (result.get(Constants.STATUS) != Status.SUCCESS) {
return result; return result;
} }
Long[] projectCodeArray = projectId == 0 ? getProjectCodesArrays(loginUser) }
: new Long[] { projectMapper.selectById(projectId).getCode() };
Long[] projectCodeArray = projectCode == 0 ? getProjectCodesArrays(loginUser)
: new Long[] { projectCode };
List<DefinitionGroupByUser> defineGroupByUsers = processDefinitionMapper.countDefinitionGroupByUser( List<DefinitionGroupByUser> defineGroupByUsers = processDefinitionMapper.countDefinitionGroupByUser(
loginUser.getId(), projectCodeArray, isAdmin(loginUser)); loginUser.getId(), projectCodeArray, isAdmin(loginUser));
......
...@@ -92,7 +92,7 @@ public class DataAnalysisControllerTest extends AbstractControllerTest { ...@@ -92,7 +92,7 @@ public class DataAnalysisControllerTest extends AbstractControllerTest {
@Test @Test
public void testCountDefinitionByUser() throws Exception { public void testCountDefinitionByUser() throws Exception {
PowerMockito.when(projectMapper.selectById(Mockito.any())).thenReturn(getProject("test")); PowerMockito.when(projectMapper.queryByCode(Mockito.any())).thenReturn(getProject("test"));
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("projectId","16"); paramsMap.add("projectId","16");
......
...@@ -237,10 +237,15 @@ public class DataAnalysisServiceTest { ...@@ -237,10 +237,15 @@ public class DataAnalysisServiceTest {
@Test @Test
public void testCountDefinitionByUser() { public void testCountDefinitionByUser() {
Mockito.when(projectMapper.selectById(Mockito.any())).thenReturn(getProject("test")); Mockito.when(projectMapper.queryByCode(Mockito.any())).thenReturn(getProject("test"));
Map<String, Object> result = new HashMap<>();
putMsg(result, Status.SUCCESS, null);
Mockito.when(projectService.checkProjectAndAuth(any(), any(), any())).thenReturn(result);
Mockito.when(processDefinitionMapper.countDefinitionGroupByUser(Mockito.anyInt(), Mockito.any(Long[].class), Mockito.when(processDefinitionMapper.countDefinitionGroupByUser(Mockito.anyInt(), Mockito.any(Long[].class),
Mockito.anyBoolean())).thenReturn(new ArrayList<DefinitionGroupByUser>()); Mockito.anyBoolean())).thenReturn(new ArrayList<DefinitionGroupByUser>());
Map<String, Object> result = dataAnalysisServiceImpl.countDefinitionByUser(user, 0); result = dataAnalysisServiceImpl.countDefinitionByUser(user, 0);
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
} }
......
...@@ -38,11 +38,11 @@ ...@@ -38,11 +38,11 @@
return { return {
isSpin: true, isSpin: true,
msg: true, msg: true,
parameter: { projectId: 0 } parameter: { projectCode: 0 }
} }
}, },
props: { props: {
projectId: Number projectCode: Number
}, },
methods: { methods: {
...mapActions('projects', ['getDefineUserCount']), ...mapActions('projects', ['getDefineUserCount']),
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
const myChart = Chart.bar('#process-definition-bar', this.defineUserList, {}) const myChart = Chart.bar('#process-definition-bar', this.defineUserList, {})
myChart.echart.setOption(bar) myChart.echart.setOption(bar)
// Jump not allowed on home page // Jump not allowed on home page
if (this.projectId) { if (this.projectCode) {
myChart.echart.on('click', e => { myChart.echart.on('click', e => {
this.$router.push({ this.$router.push({
name: 'projects-definition-list', name: 'projects-definition-list',
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
}, },
created () { created () {
this.isSpin = true this.isSpin = true
this.parameter.projectId = this.projectId this.parameter.projectCode = this.projectCode
this.getDefineUserCount(this.parameter).then(res => { this.getDefineUserCount(this.parameter).then(res => {
this.msg = res.data.count > 0 this.msg = res.data.count > 0
this.defineUserList = [] this.defineUserList = []
......
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
<span>{{$t('Process Definition Statistics')}}</span> <span>{{$t('Process Definition Statistics')}}</span>
</div> </div>
<div> <div>
<m-define-user-count :project-id="searchParams.projectId"> <m-define-user-count :project-code="searchParams.projectCode">
</m-define-user-count> </m-define-user-count>
</div> </div>
</div> </div>
...@@ -71,7 +71,6 @@ ...@@ -71,7 +71,6 @@
import mDefineUserCount from './_source/defineUserCount' import mDefineUserCount from './_source/defineUserCount'
import mTaskStatusCount from './_source/taskStatusCount' import mTaskStatusCount from './_source/taskStatusCount'
import mProcessStateCount from './_source/processStateCount' import mProcessStateCount from './_source/processStateCount'
import localStore from '@/module/util/localStorage'
import mListConstruction from '@/module/components/listConstruction/listConstruction' import mListConstruction from '@/module/components/listConstruction/listConstruction'
export default { export default {
...@@ -79,7 +78,6 @@ ...@@ -79,7 +78,6 @@
data () { data () {
return { return {
searchParams: { searchParams: {
projectId: null,
projectCode: null, projectCode: null,
startDate: '', startDate: '',
endDate: '' endDate: ''
...@@ -87,9 +85,6 @@ ...@@ -87,9 +85,6 @@
dataTime: [] dataTime: []
} }
}, },
props: {
id: Number
},
methods: { methods: {
_datepicker (val) { _datepicker (val) {
this.searchParams.startDate = val[0] this.searchParams.startDate = val[0]
...@@ -97,8 +92,7 @@ ...@@ -97,8 +92,7 @@
} }
}, },
created () { created () {
this.searchParams.projectId = this.id === 0 ? 0 : localStore.getItem('projectId') this.searchParams.projectCode = this.$route.params.projectCode == null ? 0 : this.$route.params.projectCode
this.searchParams.projectCode = this.id === 0 ? 0 : localStore.getItem('projectCode')
this.dataTime[0] = dayjs().format('YYYY-MM-DD 00:00:00') this.dataTime[0] = dayjs().format('YYYY-MM-DD 00:00:00')
this.dataTime[1] = dayjs().format('YYYY-MM-DD HH:mm:ss') this.dataTime[1] = dayjs().format('YYYY-MM-DD HH:mm:ss')
this.searchParams.startDate = this.dataTime[0] this.searchParams.startDate = this.dataTime[0]
......
...@@ -97,7 +97,7 @@ ...@@ -97,7 +97,7 @@
localStore.setItem('projectId', item.id) localStore.setItem('projectId', item.id)
localStore.setItem('projectCode', item.code) localStore.setItem('projectCode', item.code)
localStore.setItem('projectName', item.name) localStore.setItem('projectName', item.name)
this.$router.push({ path: `/projects/${item.id}/index` }) this.$router.push({ path: `/projects/${item.code}/index` })
}, },
/** /**
* Delete Project * Delete Project
......
...@@ -83,7 +83,7 @@ const router = new Router({ ...@@ -83,7 +83,7 @@ const router = new Router({
} }
}, },
{ {
path: '/projects/:projectId/index', path: '/projects/:projectCode/index',
name: 'projects-index', name: 'projects-index',
component: resolve => require(['../pages/projects/pages/index/index'], resolve), component: resolve => require(['../pages/projects/pages/index/index'], resolve),
meta: { meta: {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册