diff --git a/jasamedika-bridging/src/main/java/com/jasamedika/medifirst2000/controller/BridgingController.java b/jasamedika-bridging/src/main/java/com/jasamedika/medifirst2000/controller/BridgingController.java index 2880d604..79ca3215 100644 --- a/jasamedika-bridging/src/main/java/com/jasamedika/medifirst2000/controller/BridgingController.java +++ b/jasamedika-bridging/src/main/java/com/jasamedika/medifirst2000/controller/BridgingController.java @@ -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 bed = myDao.getQtyBed(); - Integer totalBed =0; - ArrayList ruanganId= new ArrayList(); - for(int i = 0; i ruanganId = new ArrayList(); + 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 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 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=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 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 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 addAllSubject() { + try { + pegawaiService.addCompreFaceSubject(); + return new ResponseEntity<>(null, OK); + } catch (Exception e) { + return new ResponseEntity<>(null, INTERNAL_SERVER_ERROR); + } + } + } diff --git a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/dao/PegawaiDao.java b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/dao/PegawaiDao.java index bada3c53..142ce3c7 100644 --- a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/dao/PegawaiDao.java +++ b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/dao/PegawaiDao.java @@ -1006,4 +1006,9 @@ public interface PegawaiDao extends JpaRepository, JpaSpecific @Query("select pg from Pegawai pg " + "where pg.statusEnabled is true " + "and (pg.email = :email or pg.emailAlternatif = :email)") Optional 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 findLabelFaceByJenisPegawaiDokter(); } diff --git a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/service/PegawaiService.java b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/service/PegawaiService.java index 9c836e25..26f47d34 100644 --- a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/service/PegawaiService.java +++ b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/service/PegawaiService.java @@ -180,4 +180,6 @@ public interface PegawaiService extends BaseVoService listLabelDokter = pegawaiDao.findLabelFaceByJenisPegawaiDokter(); + listLabelDokter.forEach(s -> { + try { + FaceSubjectDto dto = FaceSubjectDto.builder().subject(s).build(); + JSONObject jsonObject = new JSONObject(objectMapper.writeValueAsString(dto)); + HttpEntity httpEntity = new HttpEntity<>(jsonObject.toString(), headers); + ResponseEntity 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()); + } + }); + } + } diff --git a/jasamedika-domain/src/main/java/com/jasamedika/medifirst2000/dto/FaceSubjectDto.java b/jasamedika-domain/src/main/java/com/jasamedika/medifirst2000/dto/FaceSubjectDto.java new file mode 100644 index 00000000..5ddfbdae --- /dev/null +++ b/jasamedika-domain/src/main/java/com/jasamedika/medifirst2000/dto/FaceSubjectDto.java @@ -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; + +}