- pembuatan service cek duplikat mapping skoring tindakan medis

- perbaikan file not found exception saat get detail presensi
This commit is contained in:
salmanoe 2021-03-04 20:22:26 +07:00
parent 752679c5cb
commit 3d3ece6c53
7 changed files with 134 additions and 51 deletions

View File

@ -95,4 +95,25 @@ public interface SkoringTindakanMedisDao extends PagingAndSortingRepository<Skor
@Param("detailProduk") String detailProduk, @Param("tglMulaiBerlaku") Date tglMulaiBerlaku,
@Param("isStatusVerifikasi") Boolean statusVerifikasi);
String strCekDupSkoring = "select stm.noRec " + "from SkoringTindakanMedis stm "
+ "where stm.statusEnabled is true " + "and stm.produkId = :produkId "
+ "and stm.kelompokKerjaId = :kelompokKerjaId " + "and stm.skor = :skor "
+ "and lower(regexp_replace(stm.detailProduk,:patternText,'','g')) = :detailProduk";
String idSkoring = " and stm.noRec <> :noRec";
@Query(strCekDupSkoring)
List<String> findDupSkoring(@Param("produkId") Integer idProduk, @Param("kelompokKerjaId") Integer idKelompokKerja,
@Param("skor") Double skor, @Param("patternText") String patternText,
@Param("detailProduk") String detailProduk);
@Query(strCekDupSkoring + idSkoring)
List<String> findDupSkoring(@Param("produkId") Integer idProduk, @Param("kelompokKerjaId") Integer idKelompokKerja,
@Param("skor") Double skor, @Param("patternText") String patternText,
@Param("detailProduk") String detailProduk, @Param("noRec") String noRec);
@Query("select new Map(stm.noRec as noRec,stm.detailProduk as detailProduk) " + "from SkoringTindakanMedis stm "
+ "where stm.statusEnabled is true " + "and stm.noRec in (:listNorec)")
List<Map<String, Object>> findAllDup(@Param("listNorec") List<String> listNorec);
}

View File

@ -3,6 +3,8 @@ package com.jasamedika.medifirst2000.service;
import java.util.List;
import java.util.Map;
import org.springframework.orm.jpa.JpaSystemException;
import com.jasamedika.medifirst2000.entities.SkoringTindakanMedis;
import com.jasamedika.medifirst2000.vo.SkoringTindakanMedisVO;
@ -10,8 +12,11 @@ public interface SkoringTindakanMedisService
extends BaseVoService<SkoringTindakanMedis, SkoringTindakanMedisVO, String> {
List<Map<String, Object>> findAllEnabled(Integer idUnitKerja, Integer idKelompokKerja, Integer idProduk,
String detailProduk, Long tglMulaiBerlaku, Boolean statusVerifikasi);
String detailProduk, Long tglMulaiBerlaku, Boolean statusVerifikasi) throws JpaSystemException;
List<Map<String, Object>> findDaftarInputTindakanByRuanganKelas(Integer idRuangan);
List<Map<String, Object>> findDaftarInputTindakanByRuanganKelas(Integer idRuangan) throws JpaSystemException;
List<Map<String, Object>> findDuplicateSkoring(Integer idProduk, Integer idKelompokKerja, Double skor,
String detailProduk, String noRec) throws JpaSystemException;
}

View File

@ -43,7 +43,7 @@ import com.jasamedika.medifirst2000.vo.HabsenVO;
*/
@Service("absensiPegawaiService")
public class AbsensiPegawaiServiceImpl extends BaseVoServiceImpl implements AbsensiPegawaiService {
@Value("${presensiCapturePath}")
String presensiCapturePath;
@ -181,57 +181,62 @@ public class AbsensiPegawaiServiceImpl extends BaseVoServiceImpl implements Abse
}
}
private static String encodeFileToBase64Binary(File file) throws Exception {
FileInputStream fileInputStreamReader = new FileInputStream(file);
byte[] bytes = new byte[(int) file.length()];
fileInputStreamReader.read(bytes);
String result = new String(org.apache.commons.codec.binary.Base64.encodeBase64(bytes), "UTF-8");
private static String encodeFileToBase64Binary(File file) {
String result = "";
try {
FileInputStream fileInputStreamReader = new FileInputStream(file);
byte[] bytes = new byte[(int) file.length()];
fileInputStreamReader.read(bytes);
result = new String(org.apache.commons.codec.binary.Base64.encodeBase64(bytes), "UTF-8");
fileInputStreamReader.close();
return result;
} catch (Exception e) {
return result;
}
fileInputStreamReader.close();
return result;
}
@Override
public List<Map<String, Object>> findDetailPresensi(List<Integer> listTrNo) {
List<Map<String, Object>> result = new ArrayList<>();
try {
List<Map<String, Object>> data = habsensiDao.getDetailPresensi(listTrNo);
for (Map<String, Object> map : data) {
Map<String, Object> mapRs = new HashMap<>();
String imageURLData = "data:image/jpg;base64,"
+ encodeFileToBase64Binary(new File(getImageAbsoluteFilePath(map.get("filePath").toString())));
if (CommonUtil.isNotNullOrEmpty(map.get("filePath")) && CommonUtil.isNotNullOrEmpty(map.get("akurasi"))
&& CommonUtil.isNotNullOrEmpty(map.get("lokasi"))) {
mapRs.put("imageURLData", imageURLData);
mapRs.put("date", map.get("tanggal"));
mapRs.put("accuracy", map.get("akurasi").toString());
mapRs.put("location", map.get("lokasi"));
} else if (CommonUtil.isNullOrEmpty(map.get("filePath"))
&& CommonUtil.isNotNullOrEmpty(map.get("akurasi"))
&& CommonUtil.isNotNullOrEmpty(map.get("lokasi"))) {
mapRs.put("imageURLData", "");
mapRs.put("date", map.get("tanggal"));
mapRs.put("accuracy", map.get("akurasi").toString());
mapRs.put("location", map.get("lokasi"));
} else if (CommonUtil.isNotNullOrEmpty(map.get("filePath"))
&& CommonUtil.isNullOrEmpty(map.get("akurasi"))
&& CommonUtil.isNullOrEmpty(map.get("lokasi"))) {
mapRs.put("imageURLData", imageURLData);
mapRs.put("date", map.get("tanggal"));
mapRs.put("accuracy", "");
mapRs.put("location", "");
} else {
mapRs.put("imageURLData", "");
mapRs.put("date", "");
mapRs.put("accuracy", "");
mapRs.put("location", "");
}
result.add(mapRs);
List<Map<String, Object>> data = habsensiDao.getDetailPresensi(listTrNo);
for (Map<String, Object> map : data) {
Map<String, Object> mapRs = new HashMap<>();
String imageURLData = "";
String encodeRs = encodeFileToBase64Binary(
new File(getImageAbsoluteFilePath(map.get("filePath").toString())));
if (CommonUtil.isNotNullOrEmpty(encodeRs)) {
imageURLData = "data:image/jpg;base64," + encodeRs;
}
} catch (Exception e) {
e.printStackTrace();
if (CommonUtil.isNotNullOrEmpty(encodeRs) && CommonUtil.isNotNullOrEmpty(map.get("akurasi"))
&& CommonUtil.isNotNullOrEmpty(map.get("lokasi"))) {
mapRs.put("imageURLData", imageURLData);
mapRs.put("date", map.get("tanggal"));
mapRs.put("accuracy", map.get("akurasi").toString());
mapRs.put("location", map.get("lokasi"));
} else if (CommonUtil.isNullOrEmpty(encodeRs) && CommonUtil.isNotNullOrEmpty(map.get("akurasi"))
&& CommonUtil.isNotNullOrEmpty(map.get("lokasi"))) {
mapRs.put("imageURLData", "");
mapRs.put("date", map.get("tanggal"));
mapRs.put("accuracy", map.get("akurasi").toString());
mapRs.put("location", map.get("lokasi"));
} else if (CommonUtil.isNotNullOrEmpty(encodeRs) && CommonUtil.isNullOrEmpty(map.get("akurasi"))
&& CommonUtil.isNullOrEmpty(map.get("lokasi"))) {
mapRs.put("imageURLData", imageURLData);
mapRs.put("date", map.get("tanggal"));
mapRs.put("accuracy", "");
mapRs.put("location", "");
} else {
mapRs.put("imageURLData", "");
mapRs.put("date", "");
mapRs.put("accuracy", "");
mapRs.put("location", "");
}
result.add(mapRs);
}
return result;

View File

@ -145,7 +145,7 @@ public class IndikatorKinerjaServiceImpl extends BaseVoServiceImpl implements In
List<Map<String, Object>> result = new ArrayList<>();
List<Integer> listIdDup = new ArrayList<>();
String patternText = settingDataFixedDao.getSettingDataFixed("patternTextProduk");
String patternText = settingDataFixedDao.getSettingDataFixed("patternTextDuplicate");
String replacedNamaIndikator = namaIndikator.replaceAll(patternText, "").toLowerCase();
if (CommonUtil.isNotNullOrEmpty(idIndikator)) {
listIdDup = indikatorKinerjaDao.findDupByName(patternText, idIndikator, replacedNamaIndikator);

View File

@ -1171,7 +1171,7 @@ public class ProdukServiceImpl extends BaseAngaranServiceImpl implements ProdukS
public Map<String, Object> validateNamaProduk(Integer idProduk, String namaProduk) {
Map<String, Object> result = new HashMap<>();
String patternText = settingDataFixedDao.getSettingDataFixed("patternTextProduk");
String patternText = settingDataFixedDao.getSettingDataFixed("patternTextDuplicate");
String replacedNamaProduk = namaProduk.replaceAll(patternText, "").toLowerCase();
if (CommonUtil.isNotNullOrEmpty(idProduk)) {
List<Map<String, Object>> listNamaProduk = produkDao.checkNamaProdukLama(patternText, idProduk,

View File

@ -11,6 +11,7 @@ import org.springframework.stereotype.Service;
import com.jasamedika.medifirst2000.converter.BaseConverterImpl;
import com.jasamedika.medifirst2000.dao.ProdukDao;
import com.jasamedika.medifirst2000.dao.SettingDataFixedDao;
import com.jasamedika.medifirst2000.dao.SkoringTindakanMedisDao;
import com.jasamedika.medifirst2000.entities.Produk;
import com.jasamedika.medifirst2000.entities.SkoringTindakanMedis;
@ -40,6 +41,9 @@ public class SkoringTindakanMedisServiceImpl extends BaseVoServiceImpl implement
@Autowired
private ProdukDao produkDao;
@Autowired
private SettingDataFixedDao settingDataFixedDao;
@Override
public SkoringTindakanMedisVO add(SkoringTindakanMedisVO vo) throws JpaSystemException, ServiceVOException {
Produk produk = produkConverter.transferVOToModel(vo.getProduk(), new Produk());
@ -117,7 +121,7 @@ public class SkoringTindakanMedisServiceImpl extends BaseVoServiceImpl implement
@Override
public List<Map<String, Object>> findAllEnabled(Integer idUnitKerja, Integer idKelompokKerja, Integer idProduk,
String detailProduk, Long tglMulaiBerlaku, Boolean statusVerifikasi) {
String detailProduk, Long tglMulaiBerlaku, Boolean statusVerifikasi) throws JpaSystemException {
List<Map<String, Object>> result = new ArrayList<>();
if (CommonUtil.isNullOrEmpty(idUnitKerja) && CommonUtil.isNullOrEmpty(idKelompokKerja)
@ -186,10 +190,34 @@ public class SkoringTindakanMedisServiceImpl extends BaseVoServiceImpl implement
}
@Override
public List<Map<String, Object>> findDaftarInputTindakanByRuanganKelas(Integer idRuangan) {
public List<Map<String, Object>> findDaftarInputTindakanByRuanganKelas(Integer idRuangan)
throws JpaSystemException {
List<Map<String, Object>> result = produkDao.findDaftarInputTindakanByRuangan(idRuangan);
return result;
}
@Override
public List<Map<String, Object>> findDuplicateSkoring(Integer idProduk, Integer idKelompokKerja, Double skor,
String detailProduk, String noRec) throws JpaSystemException {
List<Map<String, Object>> result = new ArrayList<>();
List<String> listNorec = new ArrayList<>();
String patternText = settingDataFixedDao.getSettingDataFixed("patternTextDuplicate");
String replacedDetailProduk = detailProduk.replaceAll(patternText, "").toLowerCase();
if (CommonUtil.isNotNullOrEmpty(noRec)) {
listNorec = skoringTindakanMedisDao.findDupSkoring(idProduk, idKelompokKerja, skor, patternText,
replacedDetailProduk, noRec);
} else {
listNorec = skoringTindakanMedisDao.findDupSkoring(idProduk, idKelompokKerja, skor, patternText,
replacedDetailProduk);
}
if (CommonUtil.isNotNullOrEmpty(listNorec)) {
result = skoringTindakanMedisDao.findAllDup(listNorec);
}
return result;
}
}

View File

@ -405,6 +405,30 @@ public class IkiDanRemunerasiController extends LocaleController<IkiDanRemuneras
}
}
@RequestMapping(value = "/get-duplicate-skoring-tindakan-medis", method = RequestMethod.GET)
public ResponseEntity<List<Map<String, Object>>> getDuplicateSkoringTindakanMedis(HttpServletRequest request,
@RequestParam(value = "noRec", required = false) String noRec,
@RequestParam(value = "produkId", required = true) Integer idProduk,
@RequestParam(value = "kelompokKerjaId", required = true) Integer idKelompokKerja,
@RequestParam(value = "detailProduk", required = true) String detailProduk,
@RequestParam(value = "skor", required = true) Double skor) throws ParseException {
try {
List<Map<String, Object>> result = skoringTindakanMedisService.findDuplicateSkoring(idProduk,
idKelompokKerja, skor, detailProduk, noRec);
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
getMessage(MessageResource.LABEL_SUCCESS, request));
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
} catch (ServiceVOException sve) {
LOGGER.error("Got exception {} when get duplikat skoring tindakan medis", sve.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, sve.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
} catch (JpaSystemException jse) {
LOGGER.error("Got exception {} when get duplikat skoring tindakan medis", jse.getMessage());
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
}
}
@RequestMapping(value = "/save-kontrak-kinerja", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<LogbookKinerjaVO> saveKontrakKinerja(HttpServletRequest request,
@Valid @RequestBody LogbookKinerjaVO vo) {