Update service pegawai
Pembuatan service simpan subject compreface
This commit is contained in:
parent
71c1d783cb
commit
c37b4f81fe
@ -19,126 +19,139 @@ import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.jasamedika.medifirst2000.service.PegawaiService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
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.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import com.jasamedika.medifirst2000.dao.BridgingDao;
|
||||
import com.jasamedika.medifirst2000.vo.custom.BridgeBUKBorVO;
|
||||
|
||||
import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;
|
||||
import static org.springframework.http.HttpStatus.OK;
|
||||
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
|
||||
import static org.springframework.web.bind.annotation.RequestMethod.GET;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/bridging")
|
||||
public class BridgingController {
|
||||
@Autowired
|
||||
|
||||
@Autowired
|
||||
private PegawaiService pegawaiService;
|
||||
|
||||
@Autowired
|
||||
BridgingDao myDao;
|
||||
|
||||
//@Value("${reportDirectory}")
|
||||
//String reportDirectory;
|
||||
|
||||
@RequestMapping(value = "/testbor", method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_VALUE })
|
||||
public BridgeBUKBorVO test(@RequestParam(value = "bulan", required = true) String bulanTahun) throws ParseException {
|
||||
//String ret = "";
|
||||
|
||||
// @Value("${reportDirectory}")
|
||||
// String reportDirectory;
|
||||
|
||||
@RequestMapping(value = "/testbor", method = GET, produces = { APPLICATION_JSON_VALUE })
|
||||
public BridgeBUKBorVO test(@RequestParam(value = "bulan", required = true) String bulanTahun)
|
||||
throws ParseException {
|
||||
// String ret = "";
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
|
||||
|
||||
List<Object[]> bed = myDao.getQtyBed();
|
||||
Integer totalBed =0;
|
||||
ArrayList<Integer> ruanganId= new ArrayList<Integer>();
|
||||
for(int i = 0; i<bed.size();i++){
|
||||
totalBed = totalBed + ((Byte)bed.get(i)[1]).intValue();
|
||||
if(ruanganId.size()==0){
|
||||
ruanganId.add((Integer)bed.get(i)[0]);
|
||||
}else{
|
||||
boolean found=false;
|
||||
for(int j = 0;j<ruanganId.size();j++){
|
||||
if(ruanganId.get(j)==(Integer)bed.get(i)[0]){
|
||||
Integer totalBed = 0;
|
||||
ArrayList<Integer> ruanganId = new ArrayList<Integer>();
|
||||
for (int i = 0; i < bed.size(); i++) {
|
||||
totalBed = totalBed + ((Byte) bed.get(i)[1]).intValue();
|
||||
if (ruanganId.size() == 0) {
|
||||
ruanganId.add((Integer) bed.get(i)[0]);
|
||||
} else {
|
||||
boolean found = false;
|
||||
for (int j = 0; j < ruanganId.size(); j++) {
|
||||
if (ruanganId.get(j) == (Integer) bed.get(i)[0]) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!found){
|
||||
ruanganId.add((Integer)bed.get(i)[0]);
|
||||
if (!found) {
|
||||
ruanganId.add((Integer) bed.get(i)[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
System.out.println("totalBed"+ String.valueOf(totalBed));
|
||||
String bb[]= bulanTahun.split("-");
|
||||
System.out.println("totalBed" + String.valueOf(totalBed));
|
||||
String bb[] = bulanTahun.split("-");
|
||||
String bulan = bb[0].trim();
|
||||
String tahun = bb[1].trim();
|
||||
|
||||
int month = Integer.parseInt(bulan);
|
||||
int month = Integer.parseInt(bulan);
|
||||
int year = Integer.parseInt(tahun);
|
||||
|
||||
GregorianCalendar mycal = new GregorianCalendar(year,month, 1);
|
||||
int daysInMonth= mycal.getActualMaximum(Calendar.DAY_OF_MONTH);
|
||||
|
||||
Date d1 = (Date) sdf.parse("01"+"/"+bulan+"/"+tahun);
|
||||
Date d2 = (Date) sdf.parse(String.valueOf(daysInMonth)+"/"+bulan+"/"+tahun);
|
||||
|
||||
List<Object[]> x = myDao.getListPasienRanap(d1,d2);
|
||||
System.out.println( "Jumlah Pasien total" + String.valueOf(x.size()) );
|
||||
|
||||
|
||||
GregorianCalendar mycal = new GregorianCalendar(year, month, 1);
|
||||
int daysInMonth = mycal.getActualMaximum(Calendar.DAY_OF_MONTH);
|
||||
|
||||
Date d1 = (Date) sdf.parse("01" + "/" + bulan + "/" + tahun);
|
||||
Date d2 = (Date) sdf.parse(String.valueOf(daysInMonth) + "/" + bulan + "/" + tahun);
|
||||
|
||||
List<Object[]> x = myDao.getListPasienRanap(d1, d2);
|
||||
System.out.println("Jumlah Pasien total" + String.valueOf(x.size()));
|
||||
|
||||
int cnt[] = new int[daysInMonth];
|
||||
for(int i = 0;i<x.size();i++){
|
||||
for(int j = 0;j<daysInMonth;j++){
|
||||
Date tgl1 = (Date)x.get(i)[0];
|
||||
Date tgl2 = (Date)x.get(i)[1];
|
||||
String tgl1s[],tgl2s[];
|
||||
try{
|
||||
tgl1s= sdf.format(tgl1).split("/");
|
||||
String tmp1[] =tgl1s;
|
||||
if(Integer.valueOf(tmp1[0])==j){
|
||||
|
||||
for (int i = 0; i < x.size(); i++) {
|
||||
for (int j = 0; j < daysInMonth; j++) {
|
||||
Date tgl1 = (Date) x.get(i)[0];
|
||||
Date tgl2 = (Date) x.get(i)[1];
|
||||
String tgl1s[], tgl2s[];
|
||||
try {
|
||||
tgl1s = sdf.format(tgl1).split("/");
|
||||
String tmp1[] = tgl1s;
|
||||
if (Integer.valueOf(tmp1[0]) == j) {
|
||||
|
||||
}
|
||||
}catch(Exception ex){
|
||||
tgl1s= new String[0];
|
||||
} catch (Exception ex) {
|
||||
tgl1s = new String[0];
|
||||
}
|
||||
try{
|
||||
tgl2s= sdf.format(tgl2).split("/");
|
||||
}catch(Exception ex){
|
||||
tgl2s= (String.valueOf(daysInMonth)+"/"+bulan+"/"+tahun).split("/");
|
||||
try {
|
||||
tgl2s = sdf.format(tgl2).split("/");
|
||||
} catch (Exception ex) {
|
||||
tgl2s = (String.valueOf(daysInMonth) + "/" + bulan + "/" + tahun).split("/");
|
||||
}
|
||||
|
||||
if((j>=Integer.valueOf(tgl1s[0])+1)&(j<=Integer.valueOf(tgl2s[0])+1)){
|
||||
|
||||
if ((j >= Integer.valueOf(tgl1s[0]) + 1) & (j <= Integer.valueOf(tgl2s[0]) + 1)) {
|
||||
cnt[j]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
int totalCnt = 0;
|
||||
for(int i=0;i<cnt.length;i++){
|
||||
totalCnt=totalCnt+cnt[i];
|
||||
for (int i = 0; i < cnt.length; i++) {
|
||||
totalCnt = totalCnt + cnt[i];
|
||||
}
|
||||
BridgeBUKBorVO returnvalue = new BridgeBUKBorVO();
|
||||
NumberFormat formatter = new DecimalFormat("#0.00");
|
||||
|
||||
returnvalue.setBOR(Double.valueOf(formatter.format((double)(totalCnt*100)/(double)(totalBed*daysInMonth))));
|
||||
|
||||
return returnvalue ;
|
||||
NumberFormat formatter = new DecimalFormat("#0.00");
|
||||
|
||||
returnvalue.setBOR(
|
||||
Double.valueOf(formatter.format((double) (totalCnt * 100) / (double) (totalBed * daysInMonth))));
|
||||
|
||||
return returnvalue;
|
||||
}
|
||||
|
||||
|
||||
// download:
|
||||
@RequestMapping(value = "/test", method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_VALUE })
|
||||
public Map<String, Object> testFile(@RequestParam(value = "param", required = false) String param1,HttpServletResponse response) throws IOException {
|
||||
|
||||
String isiFile="halo";
|
||||
//String fileName=reportDirectory+ UUID.randomUUID().toString().replaceAll("-", "")+".txt";
|
||||
//String fileName="d:/"+ UUID.randomUUID().toString().replaceAll("-", "")+".txt";
|
||||
String fileName="d:/testfile.txt";
|
||||
@RequestMapping(value = "/test", method = GET, produces = { APPLICATION_JSON_VALUE })
|
||||
public Map<String, Object> testFile(@RequestParam(value = "param", required = false) String param1,
|
||||
HttpServletResponse response) throws IOException {
|
||||
|
||||
String isiFile = "halo";
|
||||
// String fileName=reportDirectory+
|
||||
// UUID.randomUUID().toString().replaceAll("-", "")+".txt";
|
||||
// String fileName="d:/"+ UUID.randomUUID().toString().replaceAll("-",
|
||||
// "")+".txt";
|
||||
String fileName = "d:/testfile.txt";
|
||||
FileWriter fw = new FileWriter(fileName);
|
||||
BufferedWriter bw = new BufferedWriter(fw);
|
||||
bw.write(isiFile);
|
||||
bw.write(isiFile);
|
||||
bw.flush();
|
||||
bw.close();
|
||||
|
||||
//FileOutputStream out = new FileOutputStream(fileName);
|
||||
|
||||
// FileOutputStream out = new FileOutputStream(fileName);
|
||||
|
||||
String fileType = "application/text";
|
||||
|
||||
response.setContentType(fileType);
|
||||
|
||||
// Make sure to show the download dialog
|
||||
response.setHeader("Content-disposition", "attachment; filename="+fileName);
|
||||
response.setHeader("Content-disposition", "attachment; filename=" + fileName);
|
||||
|
||||
File my_file = new File(fileName);
|
||||
// This should send the file to browser
|
||||
@ -154,5 +167,15 @@ public class BridgingController {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/compreface/subjects", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Object> addAllSubject() {
|
||||
try {
|
||||
pegawaiService.addCompreFaceSubject();
|
||||
return new ResponseEntity<>(null, OK);
|
||||
} catch (Exception e) {
|
||||
return new ResponseEntity<>(null, INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1006,4 +1006,9 @@ public interface PegawaiDao extends JpaRepository<Pegawai, Integer>, JpaSpecific
|
||||
@Query("select pg from Pegawai pg " + "where pg.statusEnabled is true "
|
||||
+ "and (pg.email = :email or pg.emailAlternatif = :email)")
|
||||
Optional<Pegawai> findByEmailOrEmailAlternatif(@Param("email") String email);
|
||||
|
||||
@Query(value = "select pg.idfinger || '_' || pg.nama from pegawai_m pg " + "where pg.statusenabled is true "
|
||||
+ "and pg.objectjenispegawaifk = 1 " + "and pg.idfinger is not null " + "and pg.idfinger <> '9999999' "
|
||||
+ "and pg.idfinger <> '' " + "order by cast(pg.idfinger as int)", nativeQuery = true)
|
||||
List<String> findLabelFaceByJenisPegawaiDokter();
|
||||
}
|
||||
|
||||
@ -180,4 +180,6 @@ public interface PegawaiService extends BaseVoService<Pegawai, PegawaiVO, Intege
|
||||
String findAvatar(Integer idPegawai);
|
||||
|
||||
void completeDataPegawai(PegawaiDto dto);
|
||||
|
||||
void addCompreFaceSubject();
|
||||
}
|
||||
|
||||
@ -1,9 +1,12 @@
|
||||
package com.jasamedika.medifirst2000.service.impl;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.jasamedika.medifirst2000.constants.Master;
|
||||
import com.jasamedika.medifirst2000.converter.PegawaiConverter;
|
||||
import com.jasamedika.medifirst2000.dao.*;
|
||||
import com.jasamedika.medifirst2000.dao.custom.PegawaiDaoCustom;
|
||||
import com.jasamedika.medifirst2000.dto.FaceSubjectDto;
|
||||
import com.jasamedika.medifirst2000.dto.PegawaiDto;
|
||||
import com.jasamedika.medifirst2000.entities.*;
|
||||
import com.jasamedika.medifirst2000.exception.ServiceVOException;
|
||||
@ -22,16 +25,22 @@ import org.joda.time.Chronology;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.joda.time.chrono.ISOChronology;
|
||||
import org.joda.time.chrono.IslamicChronology;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
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;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.orm.jpa.JpaSystemException;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.DateFormat;
|
||||
@ -39,6 +48,9 @@ import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
import static org.springframework.http.HttpMethod.POST;
|
||||
import static org.springframework.http.MediaType.APPLICATION_JSON;
|
||||
|
||||
/**
|
||||
* Implement class for PasienService
|
||||
*
|
||||
@ -46,6 +58,12 @@ import java.util.*;
|
||||
*/
|
||||
@Service("pegawaiService")
|
||||
public class PegawaiServiceImpl extends BaseVoServiceImpl implements PegawaiService {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(PegawaiServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private ObjectMapper objectMapper;
|
||||
|
||||
@Value("${systemDirectory}")
|
||||
String systemDirectory;
|
||||
|
||||
@ -2364,4 +2382,28 @@ public class PegawaiServiceImpl extends BaseVoServiceImpl implements PegawaiServ
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void addCompreFaceSubject() {
|
||||
final String uri = "http://172.16.44.34:9999/api/v1/recognition/subjects";
|
||||
RestTemplate template = new RestTemplate();
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(APPLICATION_JSON);
|
||||
headers.set("x-api-key", "2759e013-2e89-4a0e-83e1-5b57bb76f06f");
|
||||
List<String> listLabelDokter = pegawaiDao.findLabelFaceByJenisPegawaiDokter();
|
||||
listLabelDokter.forEach(s -> {
|
||||
try {
|
||||
FaceSubjectDto dto = FaceSubjectDto.builder().subject(s).build();
|
||||
JSONObject jsonObject = new JSONObject(objectMapper.writeValueAsString(dto));
|
||||
HttpEntity<Object> httpEntity = new HttpEntity<>(jsonObject.toString(), headers);
|
||||
ResponseEntity<FaceSubjectDto> exchange = template.exchange(uri, POST, httpEntity,
|
||||
FaceSubjectDto.class);
|
||||
|
||||
log.info("Try add subject ke server compreface {}", exchange.getBody().toString());
|
||||
} catch (JsonProcessingException | JSONException e) {
|
||||
throw new ServiceVOException(e.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,19 @@
|
||||
package com.jasamedika.medifirst2000.dto;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* @author salmanoe
|
||||
* @version 1.0.0
|
||||
* @since 24/10/2024
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class FaceSubjectDto {
|
||||
|
||||
private String subject;
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user