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
a7e97f5b
Commit
a7e97f5b
authored
Jun 20, 2019
by
Md Suleman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sub status sevice changes
parent
1d6f10ce
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
18 deletions
+52
-18
EmployeeController.java
.../java/com/nisum/myteam/controller/EmployeeController.java
+15
-1
ISubStatusService.java
...main/java/com/nisum/myteam/service/ISubStatusService.java
+5
-0
EmployeeService.java
...n/java/com/nisum/myteam/service/impl/EmployeeService.java
+19
-17
SubStatusService.java
.../java/com/nisum/myteam/service/impl/SubStatusService.java
+13
-0
No files found.
src/main/java/com/nisum/myteam/controller/EmployeeController.java
View file @
a7e97f5b
...
...
@@ -9,8 +9,10 @@ import java.util.stream.Collectors;
import
javax.servlet.http.HttpServletRequest
;
import
com.nisum.myteam.model.dao.EmployeeSubStatus
;
import
com.nisum.myteam.model.dao.EmployeeVisa
;
import
com.nisum.myteam.repository.EmployeeVisaRepo
;
import
com.nisum.myteam.service.ISubStatusService
;
import
com.nisum.myteam.service.impl.EmployeeService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
...
...
@@ -45,6 +47,9 @@ public class EmployeeController {
@Autowired
private
EmployeeVisaRepo
employeeVisaRepo
;
@Autowired
private
ISubStatusService
subStatusService
;
@RequestMapping
(
value
=
"/employees/{empId}"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
createEmployee
(
@RequestBody
Employee
employeeReq
,
...
...
@@ -72,7 +77,7 @@ public class EmployeeController {
if
(
empService
.
isEmployeeExistsById
(
loginEmpId
))
{
Employee
employeeUpdated
=
empService
.
updateEmployee
(
employeeReq
,
loginEmpId
);
ResponseDetails
updateRespDetails
=
new
ResponseDetails
(
new
Date
(),
906
,
empService
.
messege
,
ResponseDetails
updateRespDetails
=
new
ResponseDetails
(
new
Date
(),
906
,
empService
.
response
.
get
(
"messege"
).
toString
()
,
"Employee Updation"
,
null
,
request
.
getRequestURI
(),
"Updation Employee details"
,
employeeUpdated
);
return
new
ResponseEntity
<
ResponseDetails
>(
updateRespDetails
,
HttpStatus
.
OK
);
...
...
@@ -267,6 +272,15 @@ public class EmployeeController {
}
@RequestMapping
(
value
=
"/subStatus"
,
method
=
RequestMethod
.
PUT
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
endSubStatus
(
@RequestBody
EmployeeSubStatus
employeeSubStatus
,
@RequestParam
(
"loginEmpId"
)
String
loginEmpId
,
HttpServletRequest
request
){
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"Sub status end updated successfully"
,
"Emoployee sub status updated successfully"
,
subStatusService
.
endSubStatus
(
employeeSubStatus
)
,
request
.
getRequestURI
(),
"Resource details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
}
}
\ No newline at end of file
src/main/java/com/nisum/myteam/service/ISubStatusService.java
View file @
a7e97f5b
...
...
@@ -4,7 +4,12 @@ import com.nisum.myteam.model.dao.EmployeeSubStatus;
public
interface
ISubStatusService
{
public
EmployeeSubStatus
getLatestEmployeeSubStatus
(
String
empId
);
public
EmployeeSubStatus
updateExistingEmplyeeSubStatus
(
EmployeeSubStatus
employeeSubStatusReq
);
public
EmployeeSubStatus
addEmployeeSubStatus
(
EmployeeSubStatus
employeeSubStatus
);
public
EmployeeSubStatus
getCurrentSubStatus
(
String
employeeId
);
public
EmployeeSubStatus
endSubStatus
(
EmployeeSubStatus
subStatus
);
}
src/main/java/com/nisum/myteam/service/impl/EmployeeService.java
View file @
a7e97f5b
...
...
@@ -59,7 +59,7 @@ public class EmployeeService implements IEmployeeService {
@Autowired
private
ISubStatusService
subStatusService
;
public
String
message
=
""
;
public
Map
<
String
,
String
>
response
=
new
HashMap
<>()
;
@Override
public
Employee
createEmployee
(
Employee
employee
,
String
loginEmpId
)
throws
MyTeamException
{
...
...
@@ -78,7 +78,7 @@ public class EmployeeService implements IEmployeeService {
@Override
public
Employee
updateEmployee
(
Employee
employeeReq
,
String
loginEmpId
)
throws
ParseException
{
message
=
"Employee has been updated"
;
response
.
put
(
"messege"
,
"Employee has been updated"
)
;
// update all emp details to inactive if employee is inactive
Query
query
=
new
Query
(
Criteria
.
where
(
"employeeId"
).
is
(
employeeReq
.
getEmployeeId
()));
Update
update
=
new
Update
();
...
...
@@ -118,21 +118,22 @@ public class EmployeeService implements IEmployeeService {
//update substatus
if
(
employeeReq
.
getEmpSubStatus
()!=
null
)
{
HashMap
<
String
,
Object
>
substatus
=
(
LinkedHashMap
)
employeeReq
.
getEmpSubStatus
();
EmployeeSubStatus
latestSubStatus
=
new
EmployeeSubStatus
();
latestSubStatus
.
setEmployeeID
(
substatus
.
get
(
"employeeID"
).
toString
());
latestSubStatus
.
setSubStatus
(
substatus
.
get
(
"subStatus"
).
toString
());
latestSubStatus
.
setFromDate
(
new
SimpleDateFormat
(
"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
).
parse
(
substatus
.
get
(
"fromDate"
).
toString
()));
latestSubStatus
.
setToDate
(
new
SimpleDateFormat
(
"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
).
parse
(
substatus
.
get
(
"toDate"
).
toString
()));
EmployeeSubStatus
currentSubStatus
=
subStatusService
.
getCurrentSubStatus
(
employeeReq
.
getEmployeeId
());
if
(
currentSubStatus
!=
null
){
if
(
currentSubStatus
.
getSubStatus
().
equals
(
latestSubStatus
.
getSubStatus
()))
{
latestSubStatus
.
setId
(
currentSubStatus
.
getId
());
subStatusService
.
updateExistingEmplyeeSubStatus
(
latestSubStatus
);
}
else
{
message
=
"Employee is already "
+
currentSubStatus
.
getSubStatus
()+
" from "
+
currentSubStatus
.
getFromDate
()+
" to "
+
currentSubStatus
.
getToDate
();
}
}
else
{
HashMap
<
String
,
Object
>
substatus
=
(
LinkedHashMap
)
employeeReq
.
getEmpSubStatus
();
if
(
substatus
.
keySet
().
contains
(
"subStatus"
))
{
EmployeeSubStatus
latestSubStatus
=
new
EmployeeSubStatus
();
latestSubStatus
.
setEmployeeID
(
substatus
.
get
(
"employeeID"
).
toString
());
latestSubStatus
.
setSubStatus
(
substatus
.
get
(
"subStatus"
).
toString
());
latestSubStatus
.
setFromDate
(
new
SimpleDateFormat
(
"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
).
parse
(
substatus
.
get
(
"fromDate"
).
toString
()));
latestSubStatus
.
setToDate
(
new
SimpleDateFormat
(
"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
).
parse
(
substatus
.
get
(
"toDate"
).
toString
()));
EmployeeSubStatus
currentSubStatus
=
subStatusService
.
getCurrentSubStatus
(
employeeReq
.
getEmployeeId
());
if
(
currentSubStatus
!=
null
)
{
if
(
currentSubStatus
.
getSubStatus
().
equals
(
latestSubStatus
.
getSubStatus
()))
{
latestSubStatus
.
setId
(
currentSubStatus
.
getId
());
subStatusService
.
updateExistingEmplyeeSubStatus
(
latestSubStatus
);
}
else
{
response
.
put
(
"messege"
,
"Employee is already "
+
currentSubStatus
.
getSubStatus
()
+
" from "
+
currentSubStatus
.
getFromDate
()
+
" to "
+
currentSubStatus
.
getToDate
());
}
}
else
{
// currentSubStatus = subStatusService.getLatestEmployeeSubStatus(employeeReq.getEmployeeId());
// if(currentSubStatus == null)
subStatusService
.
addEmployeeSubStatus
(
latestSubStatus
);
...
...
@@ -140,6 +141,7 @@ public class EmployeeService implements IEmployeeService {
// latestSubStatus.setId(currentSubStatus.getId());
// subStatusService.updateExistingEmplyeeSubStatus(latestSubStatus);
// }
}
}
}
...
...
src/main/java/com/nisum/myteam/service/impl/SubStatusService.java
View file @
a7e97f5b
...
...
@@ -3,6 +3,8 @@ package com.nisum.myteam.service.impl;
import
com.nisum.myteam.model.dao.EmployeeSubStatus
;
import
com.nisum.myteam.repository.EmployeeSubStatusRepo
;
import
com.nisum.myteam.service.ISubStatusService
;
import
com.nisum.myteam.utils.MyTeamDateUtils
;
import
com.nisum.myteam.utils.MyTeamUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -52,4 +54,15 @@ public class SubStatusService implements ISubStatusService {
}
else
return
null
;
}
@Override
public
EmployeeSubStatus
endSubStatus
(
EmployeeSubStatus
subStatus
){
EmployeeSubStatus
currentSubStatus
=
getCurrentSubStatus
(
subStatus
.
getEmployeeID
());
if
(
currentSubStatus
.
getId
().
equals
(
subStatus
.
getId
())){
subStatus
.
setToDate
(
MyTeamDateUtils
.
getDayLessThanDate
(
new
Date
()));
updateExistingEmplyeeSubStatus
(
subStatus
);
}
return
null
;
}
}
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