| 23832 |
ashik.ali |
1 |
package com.spice.profitmandi.service.user;
|
|
|
2 |
|
|
|
3 |
import java.time.LocalDate;
|
|
|
4 |
import java.time.LocalDateTime;
|
|
|
5 |
|
|
|
6 |
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
7 |
import org.springframework.stereotype.Component;
|
|
|
8 |
|
|
|
9 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
|
|
10 |
import com.spice.profitmandi.dao.entity.dtr.PunchInOut;
|
|
|
11 |
import com.spice.profitmandi.dao.repository.dtr.PunchInOutRepository;
|
|
|
12 |
|
|
|
13 |
@Component
|
|
|
14 |
public class PunchInOutServiceImpl implements PunchInOutService {
|
|
|
15 |
|
|
|
16 |
@Autowired
|
|
|
17 |
private PunchInOutRepository punchInOutRepository;
|
|
|
18 |
|
|
|
19 |
@Override
|
|
|
20 |
public void punchInOut(int fofoId) throws ProfitMandiBusinessException {
|
|
|
21 |
PunchInOut punchInOut = null;
|
|
|
22 |
try {
|
|
|
23 |
punchInOut = punchInOutRepository.selectByFofoIdAndCreateDate(fofoId, LocalDate.now());
|
|
|
24 |
}catch(ProfitMandiBusinessException profitMandiBusinessException) {
|
|
|
25 |
|
|
|
26 |
}
|
|
|
27 |
if(punchInOut == null) {
|
|
|
28 |
punchInOut = new PunchInOut();
|
|
|
29 |
punchInOut.setFofoId(fofoId);
|
|
|
30 |
punchInOut.setPunchInTimestamp(LocalDateTime.now());
|
|
|
31 |
}else {
|
|
|
32 |
punchInOut.setPunchOutTimestamp(LocalDateTime.now());
|
|
|
33 |
}
|
|
|
34 |
punchInOutRepository.persist(punchInOut);
|
|
|
35 |
}
|
|
|
36 |
|
|
|
37 |
}
|