Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mytime
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Narendar Vakiti
mytime
Commits
a803632a
Commit
a803632a
authored
Jun 06, 2019
by
Vijay Akula
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added service for showing Reserved Resources
parent
777e3444
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
228 additions
and
81 deletions
+228
-81
ReportsController.java
...n/java/com/nisum/myteam/controller/ReportsController.java
+92
-75
ResourceController.java
.../java/com/nisum/myteam/controller/ResourceController.java
+14
-1
ReserveReportsVO.java
...main/java/com/nisum/myteam/model/vo/ReserveReportsVO.java
+32
-0
ResourceRepo.java
src/main/java/com/nisum/myteam/repository/ResourceRepo.java
+2
-0
IResourceService.java
src/main/java/com/nisum/myteam/service/IResourceService.java
+9
-0
ResourceService.java
...n/java/com/nisum/myteam/service/impl/ResourceService.java
+60
-5
ResourceAllocationStatus.java
...om/nisum/myteam/statuscodes/ResourceAllocationStatus.java
+19
-0
No files found.
src/main/java/com/nisum/myteam/controller/ReportsController.java
View file @
a803632a
package
com
.
nisum
.
myteam
.
controller
;
import
com.nisum.myteam.exception.handler.MyTeamException
;
import
com.nisum.myteam.exception.handler.ResponseDetails
;
import
com.nisum.myteam.model.ColumnChartData
;
import
com.nisum.myteam.model.GroupByCount
;
import
com.nisum.myteam.model.ReportSeriesRecord
;
import
com.nisum.myteam.model.dao.Account
;
import
com.nisum.myteam.model.dao.Employee
;
import
com.nisum.myteam.model.dao.Resource
;
import
com.nisum.myteam.model.vo.ReportVo
;
import
com.nisum.myteam.model.vo.ResourceVO
;
import
com.nisum.myteam.service.IAccountService
;
import
com.nisum.myteam.service.IEmployeeService
;
import
com.nisum.myteam.service.IResourceService
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -22,11 +25,9 @@ import org.springframework.data.mongodb.core.query.Query;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletRequest
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
...
...
@@ -50,6 +51,9 @@ public class ReportsController {
@Autowired
private
IResourceService
resourceService
;
@Autowired
private
IAccountService
accountService
;
//Ok Response
@RequestMapping
(
value
=
"/getEmployeesByFunctionalGroup1"
,
method
=
RequestMethod
.
GET
,
...
...
@@ -111,78 +115,8 @@ public class ReportsController {
}
/*
//Not Ok Response
@RequestMapping(value = "/getBillabilityDetailsByAccount",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<ColumnChartData> getBillabilityDetailsByAccount()
throws MyTeamException {
ProjectionOperation projectToMatchModel = project()
.andExpression("account").as("categories")
.andExpression("billableStatus").as("seriesName")
.andExpression("count").as("count");
MatchOperation matchStage = Aggregation
.match(new Criteria("active").is(true));
Aggregation aggregate = Aggregation.newAggregation(matchStage,
Aggregation.group("account", "billableStatus").count()
.as("count"),
projectToMatchModel);
// Convert the aggregation result into a List
AggregationResults<ColumnChartData> groupResults = mongoTemplate.aggregate(aggregate, Resource.class,
ColumnChartData.class);
List<ColumnChartData> result = groupResults.getMappedResults();
List<String> statusList = new ArrayList();
statusList.add("Billable");
statusList.add("Shadow");
statusList.add("Reserved");
statusList.add("Non-Billable");
List<String> catagories = new ArrayList();
List<ReportSeriesRecord> seriesDetails = new ArrayList<ReportSeriesRecord>();
List<Account> accounts = employeeService.getAccounts();
ColumnChartData reportData = new ColumnChartData();
for (String status : statusList) {
catagories = new ArrayList();
long seriesData[] = new long[accounts.size()];
int i = 0;
for (Account acct : accounts) {
boolean seriesDataExists = false;
catagories.add(acct.getAccountName());
for (ColumnChartData columnChartData : result) {
if (columnChartData.getCategories() != null
&& columnChartData.getSeriesName() != null
& columnChartData.getCategories()
.equalsIgnoreCase(
acct.getAccountName())
&& columnChartData.getSeriesName()
.equalsIgnoreCase(status)) {
seriesDataExists = true;
seriesData[i] = columnChartData.getCount();
}
}
if (!seriesDataExists) {
// seriesData[i] = 0;
}
i++;
}
ReportSeriesRecord reportSeriesRecord = new ReportSeriesRecord();
reportSeriesRecord.setName(status);
reportSeriesRecord.setData(seriesData);
seriesDetails.add(reportSeriesRecord);
}
System.out.println(seriesDetails);
reportData.setCategoriesList(catagories);
reportData.setSeriesDataList(seriesDetails);
return new ResponseEntity<>(reportData, HttpStatus.OK);
}
*/
//ok response
@RequestMapping
(
value
=
"/getBillabilityDetailsByMonth"
,
method
=
RequestMethod
.
GET
,
...
...
@@ -419,4 +353,87 @@ public class ReportsController {
return
reportVo
;
}
}
\ No newline at end of file
//Not Ok Response
@RequestMapping
(
value
=
"/getBillabilityDetailsByAccount"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
ColumnChartData
>
getBillabilityDetailsByAccount
()
throws
MyTeamException
{
ProjectionOperation
projectToMatchModel
=
project
()
.
andExpression
(
"account"
).
as
(
"categories"
)
.
andExpression
(
"billableStatus"
).
as
(
"seriesName"
)
.
andExpression
(
"count"
).
as
(
"count"
);
MatchOperation
matchStage
=
Aggregation
.
match
(
new
Criteria
(
"active"
).
is
(
true
));
Aggregation
aggregate
=
Aggregation
.
newAggregation
(
matchStage
,
Aggregation
.
group
(
"account"
,
"billableStatus"
).
count
()
.
as
(
"count"
),
projectToMatchModel
);
// Convert the aggregation result into a List
AggregationResults
<
ColumnChartData
>
groupResults
=
mongoTemplate
.
aggregate
(
aggregate
,
Resource
.
class
,
ColumnChartData
.
class
);
List
<
ColumnChartData
>
result
=
groupResults
.
getMappedResults
();
List
<
String
>
statusList
=
new
ArrayList
();
statusList
.
add
(
"Billable"
);
statusList
.
add
(
"Shadow"
);
statusList
.
add
(
"Reserved"
);
statusList
.
add
(
"Non-Billable"
);
List
<
String
>
catagories
=
new
ArrayList
();
List
<
ReportSeriesRecord
>
seriesDetails
=
new
ArrayList
<
ReportSeriesRecord
>();
//List<Account> accounts = employeeService.getAccounts();
List
<
Account
>
accounts
=
accountService
.
getAllAccounts
();
ColumnChartData
reportData
=
new
ColumnChartData
();
for
(
String
status
:
statusList
)
{
catagories
=
new
ArrayList
();
long
seriesData
[]
=
new
long
[
accounts
.
size
()];
int
i
=
0
;
for
(
Account
acct
:
accounts
)
{
boolean
seriesDataExists
=
false
;
catagories
.
add
(
acct
.
getAccountName
());
for
(
ColumnChartData
columnChartData
:
result
)
{
if
(
columnChartData
.
getCategories
()
!=
null
&&
columnChartData
.
getSeriesName
()
!=
null
&
columnChartData
.
getCategories
()
.
equalsIgnoreCase
(
acct
.
getAccountName
())
&&
columnChartData
.
getSeriesName
()
.
equalsIgnoreCase
(
status
))
{
seriesDataExists
=
true
;
seriesData
[
i
]
=
columnChartData
.
getCount
();
}
}
if
(!
seriesDataExists
)
{
// seriesData[i] = 0;
}
i
++;
}
ReportSeriesRecord
reportSeriesRecord
=
new
ReportSeriesRecord
();
reportSeriesRecord
.
setName
(
status
);
reportSeriesRecord
.
setData
(
seriesData
);
seriesDetails
.
add
(
reportSeriesRecord
);
}
System
.
out
.
println
(
seriesDetails
);
reportData
.
setCategoriesList
(
catagories
);
reportData
.
setSeriesDataList
(
seriesDetails
);
return
new
ResponseEntity
<>(
reportData
,
HttpStatus
.
OK
);
}
}
src/main/java/com/nisum/myteam/controller/ResourceController.java
View file @
a803632a
...
...
@@ -7,11 +7,13 @@ import com.nisum.myteam.model.dao.Employee;
import
com.nisum.myteam.model.dao.Resource
;
import
com.nisum.myteam.model.vo.ChangedResourceVO
;
import
com.nisum.myteam.model.vo.EmployeeShiftsVO
;
import
com.nisum.myteam.model.vo.ReserveReportsVO
;
import
com.nisum.myteam.model.vo.ResourceVO
;
import
com.nisum.myteam.repository.EmployeeVisaRepo
;
import
com.nisum.myteam.service.IEmployeeService
;
import
com.nisum.myteam.service.IProjectService
;
import
com.nisum.myteam.service.impl.ResourceService
;
import
com.nisum.myteam.statuscodes.ResourceAllocationStatus
;
import
com.nisum.myteam.utils.MyTeamUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -22,7 +24,6 @@ import org.springframework.http.ResponseEntity;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
...
...
@@ -267,5 +268,17 @@ public class ResourceController {
}
@RequestMapping
(
value
=
"/resources/reports"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
getDeliveryLeads
(
@RequestParam
(
value
=
"resourceStatus"
,
defaultValue
=
"Reserved"
)
String
resourceStatus
,
HttpServletRequest
request
)
throws
MyTeamException
{
List
<
ReserveReportsVO
>
reservedResources
=
resourceService
.
getResourceReportsByBillingStatus
(
resourceStatus
);
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
905
,
"Retrieved Resources List successfully"
,
"Resource Allocation List Details"
,
reservedResources
,
request
.
getRequestURI
(),
"Resource Allocation List Details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
getRespDetails
,
HttpStatus
.
OK
);
}
}
src/main/java/com/nisum/myteam/model/vo/ReserveReportsVO.java
0 → 100644
View file @
a803632a
package
com
.
nisum
.
myteam
.
model
.
vo
;
import
lombok.*
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
java.util.Date
;
@AllArgsConstructor
@NoArgsConstructor
@Getter
@Setter
@ToString
public
class
ReserveReportsVO
{
private
String
employeeId
;
private
String
employeeName
;
private
String
accountName
;
private
String
projectName
;
@DateTimeFormat
(
iso
=
DateTimeFormat
.
ISO
.
DATE
)
private
Date
billingStartDate
;
@DateTimeFormat
(
iso
=
DateTimeFormat
.
ISO
.
DATE
)
private
Date
billingEndDate
;
}
src/main/java/com/nisum/myteam/repository/ResourceRepo.java
View file @
a803632a
...
...
@@ -18,6 +18,8 @@ public interface ResourceRepo
List
<
Resource
>
findByEmployeeIdAndProjectId
(
String
employeeId
,
String
projectId
);
List
<
Resource
>
findByBillableStatus
(
String
resourceAllocationStatus
);
// List<Resource> findByEmployeeIdAndActive(String employeeId, boolean status);
// List<Resource> findByEmployeeIdAndProjectIdAndActive(String employeeId, String projectId, boolean status);
...
...
src/main/java/com/nisum/myteam/service/IResourceService.java
View file @
a803632a
...
...
@@ -5,8 +5,10 @@ import com.nisum.myteam.model.dao.Employee;
import
com.nisum.myteam.model.dao.Resource
;
import
com.nisum.myteam.model.vo.EmployeeShiftsVO
;
import
com.nisum.myteam.model.vo.MyProjectAllocationVO
;
import
com.nisum.myteam.model.vo.ReserveReportsVO
;
import
com.nisum.myteam.model.vo.ResourceVO
;
import
java.util.Date
;
import
java.util.List
;
public
interface
IResourceService
{
...
...
@@ -56,6 +58,13 @@ public interface IResourceService {
public
Resource
getLatestResourceByEmpId
(
String
employeeId
);
public
List
<
Resource
>
getResourcesByBillingStatus
(
String
resourceStatus
);
public
List
<
ReserveReportsVO
>
prepareReserveReports
(
List
<
Resource
>
resourcesList
);
public
List
<
ReserveReportsVO
>
getResourceReportsByBillingStatus
(
String
resourceStatus
);
// List<Resource> getAllResourcesForProject(String projectId, String status);
// List<Resource> getResourcesForEmployee(String empId);
...
...
src/main/java/com/nisum/myteam/service/impl/ResourceService.java
View file @
a803632a
...
...
@@ -2,17 +2,16 @@ package com.nisum.myteam.service.impl;
import
com.nisum.myteam.exception.handler.MyTeamException
;
import
com.nisum.myteam.model.dao.*
;
import
com.nisum.myteam.model.vo.ChangedResourceVO
;
import
com.nisum.myteam.model.vo.EmployeeShiftsVO
;
import
com.nisum.myteam.model.vo.MyProjectAllocationVO
;
import
com.nisum.myteam.model.vo.ResourceVO
;
import
com.nisum.myteam.model.vo.*
;
import
com.nisum.myteam.repository.ResourceRepo
;
import
com.nisum.myteam.service.*
;
import
com.nisum.myteam.statuscodes.ResourceAllocationStatus
;
import
com.nisum.myteam.statuscodes.ResourceStatus
;
import
com.nisum.myteam.utils.MyTeamDateUtils
;
import
com.nisum.myteam.utils.MyTeamUtils
;
import
com.nisum.myteam.utils.constants.Shifts
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
...
...
@@ -20,7 +19,6 @@ import org.springframework.data.mongodb.core.query.Criteria;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.stereotype.Service
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.stream.Collectors
;
...
...
@@ -701,6 +699,46 @@ public class ResourceService implements IResourceService {
return
null
;
}
@Override
public
List
<
Resource
>
getResourcesByBillingStatus
(
String
resourceStatus
)
{
return
resourceRepo
.
findByBillableStatus
(
resourceStatus
);
}
@Override
public
List
<
ReserveReportsVO
>
getResourceReportsByBillingStatus
(
String
resourceStatus
)
{
return
prepareReserveReports
(
getResourcesByBillingStatus
(
resourceStatus
));
}
@Override
public
List
<
ReserveReportsVO
>
prepareReserveReports
(
List
<
Resource
>
resourcesList
)
{
List
<
ReserveReportsVO
>
reserveReportsList
=
new
ArrayList
<>();
if
(
resourcesList
!=
null
&&
resourcesList
.
size
()
>
0
)
{
Project
project
=
null
;
for
(
Resource
resource
:
resourcesList
)
{
ReserveReportsVO
reserveReportsVO
=
new
ReserveReportsVO
();
reserveReportsVO
.
setEmployeeId
(
resource
.
getEmployeeId
());
reserveReportsVO
.
setEmployeeName
(
employeeService
.
getEmployeeById
(
resource
.
getEmployeeId
()).
getEmployeeName
());
if
(
StringUtils
.
isNotBlank
(
resource
.
getProjectId
()))
{
project
=
projectService
.
getProjectByProjectId
(
resource
.
getProjectId
());
if
(
project
!=
null
)
{
reserveReportsVO
.
setProjectName
(
project
.
getProjectName
());
reserveReportsVO
.
setAccountName
(
accountService
.
getAccountById
(
project
.
getAccountId
()).
getAccountName
());
}
}
reserveReportsVO
.
setBillingStartDate
(
resource
.
getBillingStartDate
());
reserveReportsVO
.
setBillingEndDate
(
resource
.
getBillingEndDate
());
reserveReportsList
.
add
(
reserveReportsVO
);
}
}
return
reserveReportsList
;
}
public
List
<
ChangedResourceVO
>
getChangedResourceByDate
(
String
fromDatestr
,
String
toDatestr
){
// List<ChangedResourceVO> changedResourceVOList = new ArrayList();
// SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");
...
...
@@ -743,6 +781,23 @@ public class ResourceService implements IResourceService {
}
public
boolean
validateResourceAllocationStatus
(
ResourceAllocationStatus
resourceStatus
)
{
boolean
isValidStatus
=
false
;
switch
(
resourceStatus
)
{
case
TRAINEE:
case
BILLABLE:
case
NON_BILLABLE:
case
RESERVED:
isValidStatus
=
true
;
break
;
}
return
isValidStatus
;
}
}
//class
...
...
src/main/java/com/nisum/myteam/statuscodes/ResourceAllocationStatus.java
0 → 100644
View file @
a803632a
package
com
.
nisum
.
myteam
.
statuscodes
;
public
enum
ResourceAllocationStatus
{
TRAINEE
(
"Trainee"
),
RESERVED
(
"Reserved"
),
BILLABLE
(
"Billable"
),
NON_BILLABLE
(
"Non-Billable"
);
private
String
status
;
private
ResourceAllocationStatus
(
String
status
)
{
this
.
status
=
status
;
}
public
String
getStatus
()
{
return
this
.
status
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment