Update PegawaiService
Pembuatan service pengumuman ulang tahun pegawai
This commit is contained in:
parent
78d0991e64
commit
16c8f44970
@ -1083,4 +1083,8 @@ public interface PegawaiDao extends PagingAndSortingRepository<Pegawai, Integer>
|
||||
public List<Map<String, Object>> checkExistingFingerId(@Param("fingerId") String idFinger,
|
||||
@Param("pegawaiId") Integer idPegawai);
|
||||
|
||||
@Query("select new Map(pg.id as id,pg.namaLengkap as namaLengkap,pg.jenisKelaminId as jenisKelaminId) "
|
||||
+ "from Pegawai pg " + "where pg.statusEnabled is true " + "and to_char(pg.tglLahir,'MM-dd') = :tglLahir")
|
||||
public List<Map<String, Object>> findByBirthDate(@Param("tglLahir") String tglLahir);
|
||||
|
||||
}
|
||||
|
||||
@ -170,4 +170,6 @@ public interface PegawaiService extends BaseVoService<Pegawai, PegawaiVO, Intege
|
||||
|
||||
List<Map<String, Object>> findExistingFingerId(String idFinger, Integer idPegawai);
|
||||
|
||||
List<Map<String, Object>> findBirthdayEmployees();
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.jasamedika.medifirst2000.service.impl;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
@ -17,6 +18,7 @@ import org.joda.time.LocalDate;
|
||||
import org.joda.time.chrono.ISOChronology;
|
||||
import org.joda.time.chrono.IslamicChronology;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
@ -72,6 +74,7 @@ import com.jasamedika.medifirst2000.paging.Filter;
|
||||
import com.jasamedika.medifirst2000.service.PegawaiService;
|
||||
import com.jasamedika.medifirst2000.util.CommonUtil;
|
||||
import com.jasamedika.medifirst2000.util.DateUtil;
|
||||
import com.jasamedika.medifirst2000.util.ImageUtil;
|
||||
import com.jasamedika.medifirst2000.util.JsonUtil;
|
||||
import com.jasamedika.medifirst2000.vo.PegawaiVO;
|
||||
import com.jasamedika.medifirst2000.vo.RegistrasiPegawaiMobileVO;
|
||||
@ -86,6 +89,9 @@ import com.jasamedika.medifirst2000.vo.RekamDataPegawaiVO;
|
||||
@Service("pegawaiService")
|
||||
public class PegawaiServiceImpl extends BaseVoServiceImpl implements PegawaiService {
|
||||
|
||||
@Value("${systemDirectory}")
|
||||
String systemDirectory;
|
||||
|
||||
@Autowired
|
||||
private PegawaiDao pegawaiDao;
|
||||
|
||||
@ -1815,6 +1821,13 @@ public class PegawaiServiceImpl extends BaseVoServiceImpl implements PegawaiServ
|
||||
Map<String, Object> result = pegawaiDao.getPegawaiDetailById(idPegawai);
|
||||
Map<String, Object> dataEvaluasiJabatan = (Map<String, Object>) this.getEvaluasiJabatanByPegawai(idPegawai);
|
||||
|
||||
String imageURLData = "";
|
||||
String encodeRs = ImageUtil.encodeFileToBase64Binary(new File(getDirPath("foto-profil") + idPegawai + ".jpg"));
|
||||
if (CommonUtil.isNotNullOrEmpty(encodeRs)) {
|
||||
imageURLData = "data:image/jpg;base64," + encodeRs;
|
||||
}
|
||||
result.put("imgUrlData", imageURLData);
|
||||
|
||||
if (CommonUtil.isNotNullOrEmpty(result.get("agamaId"))) {
|
||||
Map<String, Object> agama = agamaDao.getAgamaById(Integer.parseInt(result.get("agamaId").toString()));
|
||||
if (CommonUtil.isNotNullOrEmpty(agama)) {
|
||||
@ -2318,7 +2331,6 @@ public class PegawaiServiceImpl extends BaseVoServiceImpl implements PegawaiServ
|
||||
public String hitungMasaKerja(Date tglMasuk) {
|
||||
int years = 0;
|
||||
int months = 0;
|
||||
int days = 0;
|
||||
|
||||
Calendar birthDay = Calendar.getInstance();
|
||||
birthDay.setTimeInMillis(tglMasuk.getTime());
|
||||
@ -2343,20 +2355,6 @@ public class PegawaiServiceImpl extends BaseVoServiceImpl implements PegawaiServ
|
||||
months = 11;
|
||||
}
|
||||
|
||||
if (now.get(Calendar.DATE) > birthDay.get(Calendar.DATE))
|
||||
days = now.get(Calendar.DATE) - birthDay.get(Calendar.DATE);
|
||||
else if (now.get(Calendar.DATE) < birthDay.get(Calendar.DATE)) {
|
||||
int today = now.get(Calendar.DAY_OF_MONTH);
|
||||
now.add(Calendar.MONTH, -1);
|
||||
days = now.getActualMaximum(Calendar.DAY_OF_MONTH) - birthDay.get(Calendar.DAY_OF_MONTH) + today;
|
||||
} else {
|
||||
days = 0;
|
||||
if (months == 12) {
|
||||
years++;
|
||||
months = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return years + " tahun " + months + " bulan";
|
||||
}
|
||||
|
||||
@ -2399,4 +2397,41 @@ public class PegawaiServiceImpl extends BaseVoServiceImpl implements PegawaiServ
|
||||
return result;
|
||||
}
|
||||
|
||||
public String getDirPath(String dirname) {
|
||||
String result = "";
|
||||
|
||||
String workingDir = System.getProperty("user.dir");
|
||||
String your_os = System.getProperty("os.name").toLowerCase();
|
||||
if (your_os.indexOf("win") >= 0) {
|
||||
// if_windows
|
||||
result = workingDir + "\\" + systemDirectory + "\\" + dirname + "\\";
|
||||
} else if (your_os.indexOf("nix") >= 0 || your_os.indexOf("nux") >= 0 || your_os.indexOf("mac") >= 0) {
|
||||
// if_unix_or_mac
|
||||
result = workingDir + "//" + systemDirectory + "//" + dirname + "//";
|
||||
} else {
|
||||
// unknown_os?
|
||||
result = workingDir + "/" + systemDirectory + "/" + dirname + "/";
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> findBirthdayEmployees() {
|
||||
DateFormat df = new SimpleDateFormat("MM-dd");
|
||||
|
||||
List<Map<String, Object>> result = pegawaiDao.findByBirthDate(df.format(new Date()));
|
||||
for (Map<String, Object> map : result) {
|
||||
String imageURLData = "";
|
||||
String encodeRs = ImageUtil
|
||||
.encodeFileToBase64Binary(new File(getDirPath("foto-profil") + map.get("id").toString() + ".jpg"));
|
||||
if (CommonUtil.isNotNullOrEmpty(encodeRs)) {
|
||||
imageURLData = "data:image/jpg;base64," + encodeRs;
|
||||
}
|
||||
map.put("imgUrlData", imageURLData);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1417,4 +1417,22 @@ public class PegawaiController extends LocaleController<PegawaiVO> implements IB
|
||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-birthday", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<List<Map<String, Object>>> getBirthdayEmployee(HttpServletRequest request) {
|
||||
try {
|
||||
List<Map<String, Object>> result = pegawaiService.findBirthdayEmployees();
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
|
||||
getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
|
||||
} catch (ServiceVOException e) {
|
||||
LOGGER.error("Got exception {} when get birthday", e.getMessage());
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, e.getMessage());
|
||||
return RestUtil.getJsonResponse(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||
} catch (JpaSystemException jse) {
|
||||
LOGGER.error("Got exception {} when get birthday", jse.getMessage());
|
||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, jse.getMessage());
|
||||
return RestUtil.getJsonResponse(HttpStatus.CONFLICT, mapHeaderMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user