Update controller
Clean code
This commit is contained in:
parent
9d932fb6db
commit
60de4d71fa
@ -1,39 +1,22 @@
|
|||||||
package com.jasamedika.medifirst2000.controller;
|
package com.jasamedika.medifirst2000.controller;
|
||||||
|
|
||||||
import java.util.Collection;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
import java.util.List;
|
import com.jasamedika.medifirst2000.controller.base.LocaleController;
|
||||||
import java.util.Map;
|
import com.jasamedika.medifirst2000.entities.GenericView;
|
||||||
|
import com.jasamedika.medifirst2000.service.GenericViewService;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import com.jasamedika.medifirst2000.vo.GenericViewVO;
|
||||||
import javax.validation.Valid;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.orm.jpa.JpaSystemException;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
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.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import com.jasamedika.medifirst2000.constants.Constants;
|
import java.util.List;
|
||||||
import com.jasamedika.medifirst2000.constants.MessageResource;
|
|
||||||
import com.jasamedika.medifirst2000.controller.base.IBaseRestController;
|
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
|
||||||
import com.jasamedika.medifirst2000.controller.base.LocaleController;
|
import static org.springframework.http.HttpStatus.OK;
|
||||||
import com.jasamedika.medifirst2000.core.web.WebConstants;
|
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
|
||||||
import com.jasamedika.medifirst2000.entities.GenericView;
|
import static org.springframework.web.bind.annotation.RequestMethod.GET;
|
||||||
import com.jasamedika.medifirst2000.exception.ServiceVOException;
|
|
||||||
import com.jasamedika.medifirst2000.service.GenericViewService;
|
|
||||||
import com.jasamedika.medifirst2000.util.DateUtil;
|
|
||||||
import com.jasamedika.medifirst2000.util.rest.RestUtil;
|
|
||||||
import com.jasamedika.medifirst2000.vo.GenericViewVO;
|
|
||||||
import com.jasamedika.medifirst2000.vo.PapSkriningNyeriVO;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller class for Pengakjian Awal Gawat Darurat Business
|
* Controller class for Pengakjian Awal Gawat Darurat Business
|
||||||
@ -42,135 +25,34 @@ import com.jasamedika.medifirst2000.vo.PapSkriningNyeriVO;
|
|||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/genericView")
|
@RequestMapping("/genericView")
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public class GenericViewController extends LocaleController<GenericViewVO> implements
|
public class GenericViewController extends LocaleController<GenericViewVO> {
|
||||||
IBaseRestController<GenericViewVO> {
|
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(GenericViewController.class);
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private GenericViewService papGenericViewService;
|
private GenericViewService<GenericView> papGenericViewService;
|
||||||
|
|
||||||
@RequestMapping(value = "/StatusAdaTidakAda", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(value = "/StatusAdaTidakAda", method = GET, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
|
||||||
public ResponseEntity<List<GenericViewVO>> findAdaTidakAda(HttpServletRequest request) {
|
public ResponseEntity<List<GenericViewVO>> findAdaTidakAda(HttpServletRequest request) {
|
||||||
List<GenericViewVO> list = papGenericViewService.findGenericViewByPrevix("yaTidak");
|
List<GenericViewVO> list = papGenericViewService.findGenericViewByPrevix("yaTidak");
|
||||||
/*
|
return getJsonResponse(list, OK);
|
||||||
Boolean dataFound=new Boolean((boolean) result.get("dataFound"));
|
|
||||||
if(dataFound){
|
|
||||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
|
|
||||||
}else{
|
|
||||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_ERROR,getMessage(MessageResource.LABEL_ERROR,request ));
|
|
||||||
}*/
|
|
||||||
return RestUtil.getJsonResponse(list, HttpStatus.OK);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/StatusRegulerIrreguler", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(value = "/StatusRegulerIrreguler", method = GET, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
|
||||||
public ResponseEntity<List<GenericViewVO>> findByRegulerIrreguler(HttpServletRequest request) {
|
public ResponseEntity<List<GenericViewVO>> findByRegulerIrreguler(HttpServletRequest request) {
|
||||||
List<GenericViewVO> list = papGenericViewService.findGenericViewByPrevix("regulerIrreguler");
|
List<GenericViewVO> list = papGenericViewService.findGenericViewByPrevix("regulerIrreguler");
|
||||||
return RestUtil.getJsonResponse(list, HttpStatus.OK);
|
return getJsonResponse(list, OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/StatusNormalTidakNormal", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(value = "/StatusNormalTidakNormal", method = GET, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
|
||||||
public ResponseEntity<List<GenericViewVO>> findByNormalTidakNormal(HttpServletRequest request) {
|
public ResponseEntity<List<GenericViewVO>> findByNormalTidakNormal(HttpServletRequest request) {
|
||||||
List<GenericViewVO> list = papGenericViewService.findGenericViewByPrevix("normalTidakNormal");
|
List<GenericViewVO> list = papGenericViewService.findGenericViewByPrevix("normalTidakNormal");
|
||||||
return RestUtil.getJsonResponse(list, HttpStatus.OK);
|
return getJsonResponse(list, OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/StatusBebasTerbatas", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(value = "/DataAlatBantuNafas", method = GET, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
|
||||||
public ResponseEntity<List<GenericViewVO>> findByBebasTerbatas(HttpServletRequest request) {
|
|
||||||
List<GenericViewVO> list = papGenericViewService.findGenericViewByPrevix("bebasTerbatas");
|
|
||||||
return RestUtil.getJsonResponse(list, HttpStatus.OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "/DataAlatBantuNafas", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
public ResponseEntity<List<GenericViewVO>> findByAlatBantuNafas(HttpServletRequest request) {
|
public ResponseEntity<List<GenericViewVO>> findByAlatBantuNafas(HttpServletRequest request) {
|
||||||
List<GenericViewVO> list = papGenericViewService.findGenericViewByPrevix("alatBantuNafas");
|
List<GenericViewVO> list = papGenericViewService.findGenericViewByPrevix("alatBantuNafas");
|
||||||
return RestUtil.getJsonResponse(list, HttpStatus.OK);
|
return getJsonResponse(list, OK);
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "/Akral", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
public ResponseEntity<List<GenericViewVO>> findByAkral(HttpServletRequest request) {
|
|
||||||
List<GenericViewVO> list = papGenericViewService.findGenericViewByPrevix("akral");
|
|
||||||
return RestUtil.getJsonResponse(list, HttpStatus.OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "/Crt", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
public ResponseEntity<List<GenericViewVO>> findByCrt(HttpServletRequest request) {
|
|
||||||
List<GenericViewVO> list = papGenericViewService.findGenericViewByPrevix("crt");
|
|
||||||
return RestUtil.getJsonResponse(list, HttpStatus.OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "/IntensitasNadi", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
public ResponseEntity<List<GenericViewVO>> findByIntensitasNadi(HttpServletRequest request) {
|
|
||||||
List<GenericViewVO> list = papGenericViewService.findGenericViewByPrevix("intensitasNadi");
|
|
||||||
return RestUtil.getJsonResponse(list, HttpStatus.OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "/Kesadaran", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
public ResponseEntity<List<GenericViewVO>> findByKesadaran(HttpServletRequest request) {
|
|
||||||
List<GenericViewVO> list = papGenericViewService.findGenericViewByPrevix("kesadaran");
|
|
||||||
return RestUtil.getJsonResponse(list, HttpStatus.OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "/Mulut", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
public ResponseEntity<List<GenericViewVO>> findByMulut(HttpServletRequest request) {
|
|
||||||
List<GenericViewVO> list = papGenericViewService.findGenericViewByPrevix("mulut");
|
|
||||||
return RestUtil.getJsonResponse(list, HttpStatus.OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "/StatusPsikologi", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
public ResponseEntity<List<GenericViewVO>> findByStatusPsikologi(HttpServletRequest request) {
|
|
||||||
List<GenericViewVO> list = papGenericViewService.findGenericViewByPrevix("statusPsikologi");
|
|
||||||
return RestUtil.getJsonResponse(list, HttpStatus.OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "/TempatTinggal", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
public ResponseEntity<List<GenericViewVO>> findByTempatTinggal(HttpServletRequest request) {
|
|
||||||
List<GenericViewVO> list = papGenericViewService.findGenericViewByPrevix("tempatTinggal");
|
|
||||||
return RestUtil.getJsonResponse(list, HttpStatus.OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "/BaikTidakBaik", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
public ResponseEntity<List<GenericViewVO>> findByBaikTidakBaik(HttpServletRequest request) {
|
|
||||||
List<GenericViewVO> list = papGenericViewService.findGenericViewByPrevix("baikTidakBaik");
|
|
||||||
return RestUtil.getJsonResponse(list, HttpStatus.OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "/Test", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
public ResponseEntity<List<GenericView>> findByTest(HttpServletRequest request) {
|
|
||||||
List<GenericView> list = papGenericViewService.findGenericViewByPrevix("test");
|
|
||||||
return RestUtil.getJsonResponse(list, HttpStatus.OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResponseEntity<Collection<GenericViewVO>> getAllVOWithQueryString(HttpServletRequest request, Integer page,
|
|
||||||
Integer limit, String sort, String dir) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResponseEntity<GenericViewVO> getVO(Integer id) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResponseEntity<String> addVO(GenericViewVO vo) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResponseEntity<String> editVO(GenericViewVO vo) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResponseEntity<String> deleteVO(Integer id) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResponseEntity<List<GenericViewVO>> getAllVO() {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,40 +1,25 @@
|
|||||||
package com.jasamedika.medifirst2000.controller;
|
package com.jasamedika.medifirst2000.controller;
|
||||||
|
|
||||||
import java.util.Collection;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
import java.util.List;
|
import com.jasamedika.medifirst2000.constants.MessageResource;
|
||||||
import java.util.Map;
|
import com.jasamedika.medifirst2000.controller.base.LocaleController;
|
||||||
|
import com.jasamedika.medifirst2000.entities.GolonganDarah;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import com.jasamedika.medifirst2000.service.GolonganDarahRhesusService;
|
||||||
import javax.validation.Valid;
|
import com.jasamedika.medifirst2000.vo.GolonganDarahRhesusVO;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.orm.jpa.JpaSystemException;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
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.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import com.jasamedika.medifirst2000.constants.Constants;
|
import java.util.Map;
|
||||||
import com.jasamedika.medifirst2000.constants.MessageResource;
|
|
||||||
import com.jasamedika.medifirst2000.controller.base.IBaseRestController;
|
import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_ERROR;
|
||||||
import com.jasamedika.medifirst2000.controller.base.LocaleController;
|
import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
|
||||||
import com.jasamedika.medifirst2000.core.web.WebConstants;
|
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
|
||||||
import com.jasamedika.medifirst2000.exception.ServiceVOException;
|
import static org.springframework.http.HttpStatus.OK;
|
||||||
import com.jasamedika.medifirst2000.service.GolonganDarahRhesusService;
|
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
|
||||||
import com.jasamedika.medifirst2000.service.PapSirkulasiService;
|
import static org.springframework.web.bind.annotation.RequestMethod.GET;
|
||||||
import com.jasamedika.medifirst2000.util.DateUtil;
|
|
||||||
import com.jasamedika.medifirst2000.util.rest.RestUtil;
|
|
||||||
import com.jasamedika.medifirst2000.vo.GolonganDarahRhesusVO;
|
|
||||||
import com.jasamedika.medifirst2000.vo.PapSirkulasiVO;
|
|
||||||
import com.jasamedika.medifirst2000.vo.PapSkriningNyeriVO;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller class for Pengakjian Awal Gawat Darurat Business
|
* Controller class for Pengakjian Awal Gawat Darurat Business
|
||||||
@ -43,60 +28,23 @@ import com.jasamedika.medifirst2000.vo.PapSkriningNyeriVO;
|
|||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/gol-darah-rhesus")
|
@RequestMapping("/gol-darah-rhesus")
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public class GolonganDarahRhesusController extends LocaleController<GolonganDarahRhesusVO> implements
|
public class GolonganDarahRhesusController extends LocaleController<GolonganDarahRhesusVO> {
|
||||||
IBaseRestController<GolonganDarahRhesusVO> {
|
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(GolonganDarahRhesusController.class);
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private GolonganDarahRhesusService golonganDarahRhesusService;
|
private GolonganDarahRhesusService<GolonganDarah> golonganDarahRhesusService;
|
||||||
|
|
||||||
@RequestMapping(value = "/find-all/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(value = "/find-all/", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||||
public ResponseEntity<Map<String,Object>> findAll(HttpServletRequest request) {
|
public ResponseEntity<Map<String, Object>> findAll(HttpServletRequest request) {
|
||||||
Map<String,Object> result = golonganDarahRhesusService.findAll();
|
Map<String, Object> result = golonganDarahRhesusService.findAll();
|
||||||
Boolean dataFound=new Boolean((boolean) result.get("dataFound"));
|
boolean dataFound = (boolean) result.get("dataFound");
|
||||||
if(dataFound){
|
mapHeaderMessage.clear();
|
||||||
mapHeaderMessage.clear();
|
if (dataFound) {
|
||||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
|
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||||
}else{
|
} else {
|
||||||
mapHeaderMessage.clear();
|
mapHeaderMessage.put(LABEL_ERROR, getMessage(MessageResource.LABEL_ERROR, request));
|
||||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_ERROR,getMessage(MessageResource.LABEL_ERROR,request ));
|
|
||||||
}
|
}
|
||||||
|
return getJsonResponse(result, OK, mapHeaderMessage);
|
||||||
return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResponseEntity<Collection<GolonganDarahRhesusVO>> getAllVOWithQueryString(HttpServletRequest request,
|
|
||||||
Integer page, Integer limit, String sort, String dir) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResponseEntity<GolonganDarahRhesusVO> getVO(Integer id) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResponseEntity<String> addVO(GolonganDarahRhesusVO vo) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResponseEntity<String> editVO(GolonganDarahRhesusVO vo) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResponseEntity<String> deleteVO(Integer id) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResponseEntity<List<GolonganDarahRhesusVO>> getAllVO() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,103 +1,103 @@
|
|||||||
package com.jasamedika.medifirst2000.controller;
|
package com.jasamedika.medifirst2000.controller;
|
||||||
|
|
||||||
import java.util.Map;
|
import com.jasamedika.medifirst2000.constants.MessageResource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import com.jasamedika.medifirst2000.controller.base.LocaleController;
|
||||||
import javax.validation.Valid;
|
import com.jasamedika.medifirst2000.exception.ServiceVOException;
|
||||||
|
import com.jasamedika.medifirst2000.service.HVAService;
|
||||||
|
import com.jasamedika.medifirst2000.vo.HVAVO;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.orm.jpa.JpaSystemException;
|
import org.springframework.orm.jpa.JpaSystemException;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
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.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import com.jasamedika.medifirst2000.constants.Constants;
|
|
||||||
import com.jasamedika.medifirst2000.constants.MessageResource;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import com.jasamedika.medifirst2000.controller.base.LocaleController;
|
import javax.validation.Valid;
|
||||||
import com.jasamedika.medifirst2000.core.web.WebConstants;
|
import java.util.Map;
|
||||||
import com.jasamedika.medifirst2000.exception.ServiceVOException;
|
|
||||||
import com.jasamedika.medifirst2000.service.HVAService;
|
import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
|
||||||
import com.jasamedika.medifirst2000.util.rest.RestUtil;
|
import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
|
||||||
import com.jasamedika.medifirst2000.vo.HVAVO;
|
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus;
|
||||||
|
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
|
||||||
|
import static org.springframework.http.HttpStatus.*;
|
||||||
|
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
|
||||||
|
import static org.springframework.web.bind.annotation.RequestMethod.GET;
|
||||||
|
import static org.springframework.web.bind.annotation.RequestMethod.POST;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/hva")
|
@RequestMapping("/hva")
|
||||||
public class HVAController extends LocaleController<HVAVO> {
|
public class HVAController extends LocaleController<HVAVO> {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(HVAController.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private HVAService hvaService;
|
private HVAService hvaService;
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory
|
|
||||||
.getLogger(PegawaiController.class);
|
|
||||||
|
|
||||||
@RequestMapping(value = "/find-hva/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
public ResponseEntity<Map<String, Object>> findByJenisPeriode(
|
|
||||||
@RequestParam(value="periodeTahun") Long periodeTahun,
|
|
||||||
@RequestParam(value="jenisHVA") Integer jenisHVA,
|
|
||||||
HttpServletRequest request) {
|
|
||||||
try {
|
|
||||||
Map<String,Object> result = hvaService.findByJenisPeriode(periodeTahun, jenisHVA);
|
|
||||||
if (null != result){
|
|
||||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
|
|
||||||
return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage);
|
|
||||||
} else{
|
|
||||||
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage);
|
|
||||||
}
|
|
||||||
} catch (ServiceVOException e) {
|
|
||||||
LOGGER.error("Got exception {} when findByJenisPeriode", e.getMessage());
|
|
||||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
|
||||||
} catch (JpaSystemException jse) {
|
|
||||||
LOGGER.error("Got exception {} when findByJenisPeriode", jse.getMessage());
|
|
||||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "/save-hva/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
public ResponseEntity<Map<String, Object>> findHVAByJenisPeriode(@Valid @RequestBody HVAVO vo, HttpServletRequest request) {
|
|
||||||
try {
|
|
||||||
Map<String,Object> result = hvaService.saveHVA(vo);
|
|
||||||
if (null != result)
|
|
||||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
|
|
||||||
return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage);
|
|
||||||
|
|
||||||
} catch (ServiceVOException e) {
|
@RequestMapping(value = "/find-hva/", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||||
LOGGER.error("Got exception {} when findHVAByJenisPeriode", e.getMessage());
|
public ResponseEntity<Map<String, Object>> findByJenisPeriode(
|
||||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
@RequestParam(value = "periodeTahun") Long periodeTahun, @RequestParam(value = "jenisHVA") Integer jenisHVA,
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
|
||||||
} catch (JpaSystemException jse) {
|
|
||||||
LOGGER.error("Got exception {} when findHVAByJenisPeriode", jse.getMessage());
|
|
||||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "/get-summary-analysis", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
public ResponseEntity<Map<String, Object>> getSummaryAnalysis(
|
|
||||||
@RequestParam(value="periodeTahun") Long periodeTahun,
|
|
||||||
HttpServletRequest request) {
|
HttpServletRequest request) {
|
||||||
try {
|
try {
|
||||||
Map<String,Object> result = hvaService.getSummaryAnalysis(periodeTahun);
|
Map<String, Object> result = hvaService.findByJenisPeriode(periodeTahun, jenisHVA);
|
||||||
if (null != result){
|
if (null != result) {
|
||||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
|
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||||
return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage);
|
return getJsonResponse(result, OK, mapHeaderMessage);
|
||||||
} else{
|
} else {
|
||||||
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage);
|
return getJsonResponse(null, NOT_FOUND, mapHeaderMessage);
|
||||||
}
|
}
|
||||||
} catch (ServiceVOException e) {
|
} catch (ServiceVOException e) {
|
||||||
LOGGER.error("Got exception {} when getSummaryAnalysis", e.getMessage());
|
LOGGER.error("Got ServiceVOException {} when findByJenisPeriode", e.getMessage());
|
||||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||||
} catch (JpaSystemException jse) {
|
} catch (JpaSystemException jse) {
|
||||||
LOGGER.error("Got exception {} when getSummaryAnalysis", jse.getMessage());
|
LOGGER.error("Got JpaSystemException {} when findByJenisPeriode", jse.getMessage());
|
||||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "/save-hva/", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
|
||||||
|
public ResponseEntity<Map<String, Object>> findHVAByJenisPeriode(@Valid @RequestBody HVAVO vo,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
try {
|
||||||
|
Map<String, Object> result = hvaService.saveHVA(vo);
|
||||||
|
if (null != result)
|
||||||
|
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||||
|
return getJsonResponse(result, CREATED, mapHeaderMessage);
|
||||||
|
} catch (ServiceVOException e) {
|
||||||
|
LOGGER.error("Got ServiceVOException {} when saveHVA", e.getMessage());
|
||||||
|
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||||
|
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||||
|
} catch (JpaSystemException jse) {
|
||||||
|
LOGGER.error("Got JpaSystemException {} when saveHVA", jse.getMessage());
|
||||||
|
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||||
|
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "/get-summary-analysis", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||||
|
public ResponseEntity<Map<String, Object>> getSummaryAnalysis(
|
||||||
|
@RequestParam(value = "periodeTahun") Long periodeTahun, HttpServletRequest request) {
|
||||||
|
try {
|
||||||
|
Map<String, Object> result = hvaService.getSummaryAnalysis(periodeTahun);
|
||||||
|
if (null != result) {
|
||||||
|
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||||
|
return getJsonResponse(result, OK, mapHeaderMessage);
|
||||||
|
} else {
|
||||||
|
return getJsonResponse(null, NOT_FOUND, mapHeaderMessage);
|
||||||
|
}
|
||||||
|
} catch (ServiceVOException e) {
|
||||||
|
LOGGER.error("Got ServiceVOException {} when getSummaryAnalysis", e.getMessage());
|
||||||
|
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||||
|
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||||
|
} catch (JpaSystemException jse) {
|
||||||
|
LOGGER.error("Got JpaSystemException {} when getSummaryAnalysis", jse.getMessage());
|
||||||
|
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||||
|
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,38 +1,26 @@
|
|||||||
package com.jasamedika.medifirst2000.controller;
|
package com.jasamedika.medifirst2000.controller;
|
||||||
|
|
||||||
import java.util.Collection;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
import java.util.List;
|
import com.jasamedika.medifirst2000.constants.MessageResource;
|
||||||
import java.util.Map;
|
import com.jasamedika.medifirst2000.controller.base.LocaleController;
|
||||||
|
import com.jasamedika.medifirst2000.entities.HasilPemeriksaanPraKerja;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import com.jasamedika.medifirst2000.service.HasilPemeriksaanPraKerjaService;
|
||||||
import javax.validation.Valid;
|
import com.jasamedika.medifirst2000.vo.HasilPemeriksaanPraKerjaVO;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.orm.jpa.JpaSystemException;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
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.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import com.jasamedika.medifirst2000.constants.Constants;
|
import java.util.Map;
|
||||||
import com.jasamedika.medifirst2000.constants.MessageResource;
|
|
||||||
import com.jasamedika.medifirst2000.controller.base.IBaseRestController;
|
import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_ERROR;
|
||||||
import com.jasamedika.medifirst2000.controller.base.LocaleController;
|
import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
|
||||||
import com.jasamedika.medifirst2000.core.web.WebConstants;
|
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
|
||||||
import com.jasamedika.medifirst2000.exception.ServiceVOException;
|
import static org.springframework.http.HttpStatus.OK;
|
||||||
import com.jasamedika.medifirst2000.service.HasilPemeriksaanPraKerjaService;
|
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
|
||||||
import com.jasamedika.medifirst2000.util.DateUtil;
|
import static org.springframework.web.bind.annotation.RequestMethod.GET;
|
||||||
import com.jasamedika.medifirst2000.util.rest.RestUtil;
|
|
||||||
import com.jasamedika.medifirst2000.vo.HasilPemeriksaanPraKerjaVO;
|
|
||||||
import com.jasamedika.medifirst2000.vo.PapSkriningNyeriVO;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller class for Pengakjian Awal Gawat Darurat Business
|
* Controller class for Pengakjian Awal Gawat Darurat Business
|
||||||
@ -41,83 +29,23 @@ import com.jasamedika.medifirst2000.vo.PapSkriningNyeriVO;
|
|||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/hasil-pemeriksaan-pra-kerja")
|
@RequestMapping("/hasil-pemeriksaan-pra-kerja")
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public class HasilPemeriksaanPraKerjaController extends LocaleController<HasilPemeriksaanPraKerjaVO> implements
|
public class HasilPemeriksaanPraKerjaController extends LocaleController<HasilPemeriksaanPraKerjaVO> {
|
||||||
IBaseRestController<HasilPemeriksaanPraKerjaVO> {
|
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(HasilPemeriksaanPraKerjaController.class);
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private HasilPemeriksaanPraKerjaService hasilPemeriksaanPraKerjaService;
|
private HasilPemeriksaanPraKerjaService<HasilPemeriksaanPraKerja> hasilPemeriksaanPraKerjaService;
|
||||||
|
|
||||||
@RequestMapping(value = "/save-hasil-pemeriksaan-pra-kerja", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(value = "/find-by-pegawai-id/", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||||
public ResponseEntity<Map<String,Object>> save(@Valid @RequestBody HasilPemeriksaanPraKerjaVO vo,HttpServletRequest request) {
|
public ResponseEntity<Map<String, Object>> findByPegawaiId(
|
||||||
try {
|
@RequestParam(value = "pegawaiId", required = false) Integer pegawaiId, HttpServletRequest request) {
|
||||||
Map<String,Object> result = hasilPemeriksaanPraKerjaService.addHasilPemeriksaanPraKerja(vo);
|
Map<String, Object> result = hasilPemeriksaanPraKerjaService.findByPegawaiId(pegawaiId);
|
||||||
|
boolean dataFound = (boolean) result.get("dataFound");
|
||||||
if (null != result){
|
if (dataFound) {
|
||||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
|
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||||
}else{
|
} else {
|
||||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_ERROR,getMessage(MessageResource.LABEL_ERROR,request ));
|
mapHeaderMessage.put(LABEL_ERROR, getMessage(MessageResource.LABEL_ERROR, request));
|
||||||
}
|
|
||||||
return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage);
|
|
||||||
|
|
||||||
} catch (ServiceVOException e) {
|
|
||||||
LOGGER.error("Got exception {} when add HasilPemeriksaanPraKerja", e.getMessage());
|
|
||||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
|
||||||
} catch (JpaSystemException jse) {
|
|
||||||
LOGGER.error("Got exception {} when add HasilPemeriksaanPraKerja", jse.getMessage());
|
|
||||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
|
||||||
}
|
}
|
||||||
|
return getJsonResponse(result, OK, mapHeaderMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/find-by-pegawai-id/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
public ResponseEntity<Map<String,Object>> findByPegawaiId(@RequestParam(value = "pegawaiId", required = false) Integer pegawaiId,HttpServletRequest request) {
|
|
||||||
Map<String,Object> result = hasilPemeriksaanPraKerjaService.findByPegawaiId(pegawaiId);
|
|
||||||
Boolean dataFound=new Boolean((boolean) result.get("dataFound"));
|
|
||||||
if(dataFound){
|
|
||||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
|
|
||||||
}else{
|
|
||||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_ERROR,getMessage(MessageResource.LABEL_ERROR,request ));
|
|
||||||
}
|
|
||||||
|
|
||||||
return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResponseEntity<Collection<HasilPemeriksaanPraKerjaVO>> getAllVOWithQueryString(HttpServletRequest request,
|
|
||||||
Integer page, Integer limit, String sort, String dir) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResponseEntity<HasilPemeriksaanPraKerjaVO> getVO(Integer id) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResponseEntity<String> addVO(HasilPemeriksaanPraKerjaVO vo) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResponseEntity<String> editVO(HasilPemeriksaanPraKerjaVO vo) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResponseEntity<String> deleteVO(Integer id) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResponseEntity<List<HasilPemeriksaanPraKerjaVO>> getAllVO() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,222 +1,131 @@
|
|||||||
package com.jasamedika.medifirst2000.controller;
|
package com.jasamedika.medifirst2000.controller;
|
||||||
|
|
||||||
import java.util.List;
|
import com.jasamedika.medifirst2000.constants.MessageResource;
|
||||||
import java.util.Map;
|
import com.jasamedika.medifirst2000.controller.base.LocaleController;
|
||||||
|
import com.jasamedika.medifirst2000.entities.HasilPemeriksaanSwaPantauLimbahCair;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import com.jasamedika.medifirst2000.exception.ServiceVOException;
|
||||||
import javax.validation.Valid;
|
import com.jasamedika.medifirst2000.service.HasilPemeriksaanSwaPantauLimbahCairService;
|
||||||
|
import com.jasamedika.medifirst2000.vo.HasilPemeriksaanSwaPantauLimbahCairVO;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.jpa.domain.Specification;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.orm.jpa.JpaSystemException;
|
import org.springframework.orm.jpa.JpaSystemException;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.*;
|
||||||
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.ResponseBody;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
import com.jasamedika.medifirst2000.constants.Constants;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import com.jasamedika.medifirst2000.constants.MessageResource;
|
import javax.validation.Valid;
|
||||||
import com.jasamedika.medifirst2000.controller.base.LocaleController;
|
import java.util.Map;
|
||||||
import com.jasamedika.medifirst2000.core.web.WebConstants;
|
|
||||||
import com.jasamedika.medifirst2000.entities.Ruangan;
|
|
||||||
import com.jasamedika.medifirst2000.exception.ServiceVOException;
|
|
||||||
import com.jasamedika.medifirst2000.service.BakuMutuService;
|
|
||||||
import com.jasamedika.medifirst2000.service.HasilPemeriksaanSwaPantauLimbahCairService;
|
|
||||||
import com.jasamedika.medifirst2000.util.rest.RestUtil;
|
|
||||||
import com.jasamedika.medifirst2000.vo.BakuMutuVO;
|
|
||||||
import com.jasamedika.medifirst2000.vo.HasilPemeriksaanSwaPantauLimbahCairVO;
|
|
||||||
|
|
||||||
import net.kaczmarzyk.spring.data.jpa.domain.LessThanOrEqual;
|
import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
|
||||||
import net.kaczmarzyk.spring.data.jpa.web.annotation.Spec;
|
import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
|
||||||
|
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus;
|
||||||
|
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
|
||||||
|
import static org.springframework.http.HttpStatus.*;
|
||||||
|
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
|
||||||
|
import static org.springframework.web.bind.annotation.RequestMethod.GET;
|
||||||
|
import static org.springframework.web.bind.annotation.RequestMethod.POST;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/hasil-pemeriksaan-swa-pantau-limbah-cair")
|
@RequestMapping("/hasil-pemeriksaan-swa-pantau-limbah-cair")
|
||||||
public class HasilPemeriksaanSwaPantauLimbahCairController extends LocaleController<HasilPemeriksaanSwaPantauLimbahCairVO> {
|
public class HasilPemeriksaanSwaPantauLimbahCairController
|
||||||
|
extends LocaleController<HasilPemeriksaanSwaPantauLimbahCairVO> {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(HasilPemeriksaanSwaPantauLimbahCairController.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private HasilPemeriksaanSwaPantauLimbahCairService hasilPemeriksaanSwaPantauLimbahCairService;
|
private HasilPemeriksaanSwaPantauLimbahCairService<HasilPemeriksaanSwaPantauLimbahCair> hasilPemeriksaanSwaPantauLimbahCairService;
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory
|
@RequestMapping(value = "/save-hasil-pemeriksaan-swa-pantau-limbah-cair/", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
|
||||||
.getLogger(BakuMutuController.class);
|
public ResponseEntity<Map<String, Object>> addVO(@Valid @RequestBody HasilPemeriksaanSwaPantauLimbahCairVO vo,
|
||||||
|
HttpServletRequest request) {
|
||||||
@RequestMapping(value = "/save-hasil-pemeriksaan-swa-pantau-limbah-cair/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
public ResponseEntity<Map<String,Object>> addVO(@Valid @RequestBody HasilPemeriksaanSwaPantauLimbahCairVO vo,HttpServletRequest request) {
|
|
||||||
|
|
||||||
try{
|
|
||||||
Map<String, Object> result = hasilPemeriksaanSwaPantauLimbahCairService.addHasilPemeriksaanSwaPantauLimbahCair(vo);
|
|
||||||
if (null != result)
|
|
||||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS,request));
|
|
||||||
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
|
|
||||||
} catch (ServiceVOException e) {
|
|
||||||
LOGGER.error("Got exception {} when add hasilPemeriksaanSwaPantauLimbahCair", e.getMessage());
|
|
||||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
|
|
||||||
e.getMessage());
|
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR,
|
|
||||||
mapHeaderMessage);
|
|
||||||
|
|
||||||
} catch (JpaSystemException jse) {
|
|
||||||
LOGGER.error("Got exception {} when add hasilPemeriksaanSwaPantauLimbahCair", jse.getMessage());
|
|
||||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
|
|
||||||
jse.getMessage());
|
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT,
|
|
||||||
mapHeaderMessage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "/find-all-hasil-pemeriksaan-swa-pantau-limbah-cair/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
public ResponseEntity<Map<String,Object>> getAllVO(HttpServletRequest request) {
|
|
||||||
|
|
||||||
try {
|
|
||||||
Map<String,Object> result=hasilPemeriksaanSwaPantauLimbahCairService.findAllhasilPemeriksaanSwaPantauLimbahCair();
|
|
||||||
if (null != result)
|
|
||||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
|
|
||||||
return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage);
|
|
||||||
} catch (ServiceVOException e) {
|
|
||||||
LOGGER.error("Got exception {} when get all hasilPemeriksaanSwaPantauLimbahCair", e.getMessage());
|
|
||||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
|
|
||||||
e.getMessage());
|
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR,
|
|
||||||
mapHeaderMessage);
|
|
||||||
} catch (JpaSystemException jse) {
|
|
||||||
LOGGER.error("Got exception {} when get all hasilPemeriksaanSwaPantauLimbahCair", jse.getMessage());
|
|
||||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
|
|
||||||
jse.getMessage());
|
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT,
|
|
||||||
mapHeaderMessage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "/delete-hasil-pemeriksaan-swa-pantau-limbah-cair", method = RequestMethod.GET)
|
|
||||||
public ResponseEntity<String> deleteNamaBahan(@RequestParam(value = "noRec", required = true) String noRec) {
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (hasilPemeriksaanSwaPantauLimbahCairService.deleteHasilPemeriksaanSwaPantauLimbahCair(noRec) == true)
|
Map<String, Object> result = hasilPemeriksaanSwaPantauLimbahCairService
|
||||||
return RestUtil.getJsonResponse(noRec +" Dihapus", HttpStatus.CREATED);
|
.addHasilPemeriksaanSwaPantauLimbahCair(vo);
|
||||||
|
if (null != result)
|
||||||
|
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||||
|
return getJsonResponse(result, CREATED, mapHeaderMessage);
|
||||||
} catch (ServiceVOException e) {
|
} catch (ServiceVOException e) {
|
||||||
LOGGER.error("Got exception {} when delete hasilPemeriksaanSwaPantauLimbahCair", e.getMessage());
|
LOGGER.error("Got ServiceVOException {} when addHasilPemeriksaanSwaPantauLimbahCair", e.getMessage());
|
||||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
|
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||||
e.getMessage());
|
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR,
|
|
||||||
mapHeaderMessage);
|
|
||||||
} catch (JpaSystemException jse) {
|
} catch (JpaSystemException jse) {
|
||||||
LOGGER.error("Got exception {} when delete hasilPemeriksaanSwaPantauLimbahCair", jse.getMessage());
|
LOGGER.error("Got JpaSystemException {} when addHasilPemeriksaanSwaPantauLimbahCair", jse.getMessage());
|
||||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
|
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||||
jse.getMessage());
|
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT,
|
|
||||||
mapHeaderMessage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.NOT_ACCEPTABLE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@RequestMapping(value = "/find-all-hasil-pemeriksaan-swa-pantau-limbah-cair/", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||||
|
public ResponseEntity<Map<String, Object>> getAllVO(HttpServletRequest request) {
|
||||||
|
try {
|
||||||
|
Map<String, Object> result = hasilPemeriksaanSwaPantauLimbahCairService
|
||||||
|
.findAllhasilPemeriksaanSwaPantauLimbahCair();
|
||||||
|
if (null != result)
|
||||||
|
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||||
|
return getJsonResponse(result, CREATED, mapHeaderMessage);
|
||||||
|
} catch (ServiceVOException e) {
|
||||||
|
LOGGER.error("Got ServiceVOException {} when findAllhasilPemeriksaanSwaPantauLimbahCair", e.getMessage());
|
||||||
|
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||||
|
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||||
|
} catch (JpaSystemException jse) {
|
||||||
|
LOGGER.error("Got JpaSystemException {} when findAllhasilPemeriksaanSwaPantauLimbahCair", jse.getMessage());
|
||||||
|
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||||
|
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "/delete-hasil-pemeriksaan-swa-pantau-limbah-cair", method = GET)
|
||||||
|
public ResponseEntity<String> deleteNamaBahan(@RequestParam(value = "noRec") String noRec) {
|
||||||
|
try {
|
||||||
|
if (hasilPemeriksaanSwaPantauLimbahCairService.deleteHasilPemeriksaanSwaPantauLimbahCair(noRec))
|
||||||
|
return getJsonResponse(noRec + " Dihapus", CREATED);
|
||||||
|
} catch (ServiceVOException e) {
|
||||||
|
LOGGER.error("Got ServiceVOException {} when deleteHasilPemeriksaanSwaPantauLimbahCair", e.getMessage());
|
||||||
|
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||||
|
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||||
|
} catch (JpaSystemException jse) {
|
||||||
|
LOGGER.error("Got JpaSystemException {} when deleteHasilPemeriksaanSwaPantauLimbahCair", jse.getMessage());
|
||||||
|
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||||
|
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||||
|
}
|
||||||
|
return getJsonHttpStatus(NOT_ACCEPTABLE);
|
||||||
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/list-hasil-pemeriksaan-limbah-cair")
|
@RequestMapping(value = "/list-hasil-pemeriksaan-limbah-cair")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Map<String,Object> listHasilPemeriksaanLimbahCair(
|
public Map<String, Object> listHasilPemeriksaanLimbahCair(
|
||||||
@RequestParam(value = "page", required = false, defaultValue = "0") Integer page,
|
@RequestParam(value = "page", required = false, defaultValue = "0") Integer page,
|
||||||
@RequestParam(value = "take", required = false, defaultValue = "100") Integer limit,
|
@RequestParam(value = "take", required = false, defaultValue = "100") Integer limit,
|
||||||
@RequestParam(value = "sort", required = false, defaultValue = "noRec") String sort,
|
@RequestParam(value = "sort", required = false, defaultValue = "noRec") String sort,
|
||||||
@RequestParam(value = "dir", required = false, defaultValue = "asc") String dir,
|
@RequestParam(value = "dir", required = false, defaultValue = "asc") String dir,
|
||||||
@RequestParam(value = "dateStart", required = false) String dateStart,
|
@RequestParam(value = "dateStart", required = false) String dateStart,
|
||||||
@RequestParam(value = "dateEnd", required = false) String dateEnd) {
|
@RequestParam(value = "dateEnd", required = false) String dateEnd) {
|
||||||
|
return hasilPemeriksaanSwaPantauLimbahCairService.listHasilPemeriksaanSwaLimbahCair(page, limit, sort, dir,
|
||||||
|
dateStart, dateEnd);
|
||||||
|
}
|
||||||
|
|
||||||
Map<String, Object> resultPageMap = hasilPemeriksaanSwaPantauLimbahCairService.listHasilPemeriksaanSwaLimbahCair(page, limit, sort, dir, dateStart, dateEnd);
|
|
||||||
return resultPageMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping(value = "/get-inlet-meter-lalu/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
public ResponseEntity<Map<String,Double>> getInletMeterLalu(HttpServletRequest request) {
|
|
||||||
|
|
||||||
try {
|
|
||||||
Map<String,Double> result=hasilPemeriksaanSwaPantauLimbahCairService.getInletMeterAirLalu();
|
|
||||||
if (null != result)
|
|
||||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
|
|
||||||
return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage);
|
|
||||||
} catch (ServiceVOException e) {
|
|
||||||
LOGGER.error("Got exception {} when get inlet", e.getMessage());
|
|
||||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
|
|
||||||
e.getMessage());
|
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR,
|
|
||||||
mapHeaderMessage);
|
|
||||||
} catch (JpaSystemException jse) {
|
|
||||||
LOGGER.error("Got exception {} when get all hasilPemeriksaanSwaPantauLimbahCair", jse.getMessage());
|
|
||||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
|
|
||||||
jse.getMessage());
|
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT,
|
|
||||||
mapHeaderMessage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "/get-outlet-meter-lalu/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
public ResponseEntity<Map<String,Double>> getOutletMeterLalu(HttpServletRequest request) {
|
|
||||||
|
|
||||||
try {
|
|
||||||
Map<String,Double> result=hasilPemeriksaanSwaPantauLimbahCairService.getOutletMeterAirLalu();
|
|
||||||
if (null != result)
|
|
||||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request ));
|
|
||||||
return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage);
|
|
||||||
} catch (ServiceVOException e) {
|
|
||||||
LOGGER.error("Got exception {} when get outlet", e.getMessage());
|
|
||||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
|
|
||||||
e.getMessage());
|
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR,
|
|
||||||
mapHeaderMessage);
|
|
||||||
} catch (JpaSystemException jse) {
|
|
||||||
LOGGER.error("Got exception {} when get all hasilPemeriksaanSwaPantauLimbahCair", jse.getMessage());
|
|
||||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE,
|
|
||||||
jse.getMessage());
|
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT,
|
|
||||||
mapHeaderMessage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "/hasil-pemeriksaan-limbah-cair-detail")
|
@RequestMapping(value = "/hasil-pemeriksaan-limbah-cair-detail")
|
||||||
public Map<String,Object> hasilPemeriksaanLimbahCairDetail(
|
public Map<String, Object> hasilPemeriksaanLimbahCairDetail(@RequestParam(value = "noRec") String noRec) {
|
||||||
@RequestParam(value = "noRec", required = true) String noRec) {
|
return hasilPemeriksaanSwaPantauLimbahCairService.hasilPemeriksaanLimbahCairDetail(noRec);
|
||||||
|
|
||||||
Map<String, Object> resultPageMap = hasilPemeriksaanSwaPantauLimbahCairService.hasilPemeriksaanLimbahCairDetail(noRec);
|
|
||||||
|
|
||||||
return resultPageMap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/get-hasil-pemeriksaan-pantau-limbah-cair")
|
|
||||||
public Map<String,Object> getHasilPemeriksaanPantauLimbahCair(
|
|
||||||
@RequestParam(value = "startDate", required = true) String startDate, @RequestParam(value="endDate", required=true)String endDate) {
|
|
||||||
|
|
||||||
Map<String, Object> resultPageMap = this.hasilPemeriksaanSwaPantauLimbahCairService.getHasilPemeriksaanPantauLImbahCair(startDate, endDate);
|
|
||||||
|
|
||||||
return resultPageMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping("/lapHasilPemeriksaanSWAPantauLimbahCair")
|
@RequestMapping("/lapHasilPemeriksaanSWAPantauLimbahCair")
|
||||||
public ModelAndView generateLapHasilPemeriksaanSWAPantauLimbahCair(ModelAndView m,
|
public ModelAndView generateLapHasilPemeriksaanSWAPantauLimbahCair(ModelAndView m,
|
||||||
@RequestParam(value = "format", required = false) String format,
|
@RequestParam(value = "format", required = false) String format,
|
||||||
@RequestParam(value = "startDate", required = false) String startDate,
|
@RequestParam(value = "startDate", required = false) String startDate,
|
||||||
@RequestParam(value = "endDate", required = false) String endDate) {
|
@RequestParam(value = "endDate", required = false) String endDate) {
|
||||||
|
Map<String, Object> result = this.hasilPemeriksaanSwaPantauLimbahCairService
|
||||||
Map<String, Object> result = this.hasilPemeriksaanSwaPantauLimbahCairService.getHasilPemeriksaanPantauLImbahCair(startDate, endDate);
|
.getHasilPemeriksaanPantauLImbahCair(startDate, endDate);
|
||||||
|
|
||||||
Map<String, Object> header = (Map<String, Object>) result.get("header");
|
Map<String, Object> header = (Map<String, Object>) result.get("header");
|
||||||
String periode = header.get("tanggalAwal") == null ? "" : (String) header.get("tanggalAwal");
|
String periode = header.get("tanggalAwal") == null ? "" : (String) header.get("tanggalAwal");
|
||||||
periode = periode + (header.get("tanggalAkhir") == null ? "" : " sd " + (String) header.get("tanggalAkhir"));
|
periode = periode + (header.get("tanggalAkhir") == null ? "" : " sd " + header.get("tanggalAkhir"));
|
||||||
m.addObject("dataSource", result.get("listData"));
|
m.addObject("dataSource", result.get("listData"));
|
||||||
m.addObject("periode", periode);
|
m.addObject("periode", periode);
|
||||||
m.addObject("format", "pdf");
|
m.addObject("format", "pdf");
|
||||||
if (format != null && !format.isEmpty()) {
|
if (format != null && !format.isEmpty())
|
||||||
m.addObject("format", format);
|
m.addObject("format", format);
|
||||||
}
|
|
||||||
|
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,226 +1,165 @@
|
|||||||
package com.jasamedika.medifirst2000.controller;
|
package com.jasamedika.medifirst2000.controller;
|
||||||
|
|
||||||
import java.util.Map;
|
import com.jasamedika.medifirst2000.constants.MessageResource;
|
||||||
|
import com.jasamedika.medifirst2000.controller.base.LocaleController;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import com.jasamedika.medifirst2000.exception.ServiceVOException;
|
||||||
import javax.validation.Valid;
|
import com.jasamedika.medifirst2000.service.HistoriPelayananCsService;
|
||||||
|
import com.jasamedika.medifirst2000.vo.HistoriPelayananCsVO;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.orm.jpa.JpaSystemException;
|
import org.springframework.orm.jpa.JpaSystemException;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
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.ResponseBody;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import com.jasamedika.medifirst2000.base.vo.BaseModelVO;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import com.jasamedika.medifirst2000.constants.Constants;
|
import javax.validation.Valid;
|
||||||
import com.jasamedika.medifirst2000.constants.MessageResource;
|
import java.util.Map;
|
||||||
import com.jasamedika.medifirst2000.controller.base.LocaleController;
|
|
||||||
import com.jasamedika.medifirst2000.core.web.WebConstants;
|
|
||||||
import com.jasamedika.medifirst2000.entities.HistoriPelayananCs;
|
|
||||||
import com.jasamedika.medifirst2000.exception.ServiceVOException;
|
|
||||||
import com.jasamedika.medifirst2000.service.HistoriPelayananCsService;
|
|
||||||
import com.jasamedika.medifirst2000.util.rest.RestUtil;
|
|
||||||
import com.jasamedika.medifirst2000.vo.AkunVO;
|
|
||||||
import com.jasamedika.medifirst2000.vo.HistoriPelayananCsVO;
|
|
||||||
import com.jasamedika.medifirst2000.vo.JadwalDokter_VO;
|
|
||||||
import com.jasamedika.medifirst2000.vo.PlanningPegawaiStatusVO;
|
|
||||||
import com.mysema.query.types.Constant;
|
|
||||||
|
|
||||||
|
import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
|
||||||
|
import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
|
||||||
|
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus;
|
||||||
|
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
|
||||||
|
import static org.springframework.http.HttpStatus.*;
|
||||||
|
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
|
||||||
|
import static org.springframework.web.bind.annotation.RequestMethod.GET;
|
||||||
|
import static org.springframework.web.bind.annotation.RequestMethod.POST;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/historiPelayananCs")
|
@RequestMapping("/historiPelayananCs")
|
||||||
public class HistoriPelayananCsController extends LocaleController<HistoriPelayananCsVO> {
|
public class HistoriPelayananCsController extends LocaleController<HistoriPelayananCsVO> {
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(HistoriPelayananCsController.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(HistoriPelayananCsController.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private HistoriPelayananCsService historiPelayananCsService;
|
private HistoriPelayananCsService historiPelayananCsService;
|
||||||
|
|
||||||
@RequestMapping(value = "/save-histori-pelayanancs",
|
|
||||||
method = RequestMethod.POST,
|
|
||||||
produces = MediaType.APPLICATION_JSON_VALUE,
|
|
||||||
consumes = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
public ResponseEntity<Map<String,Object>> saveHistoriPelayananCs(
|
|
||||||
@Valid @RequestBody HistoriPelayananCsVO hpcsvo, HttpServletRequest request) {
|
|
||||||
|
|
||||||
try {
|
|
||||||
Map<String,Object> result = this.historiPelayananCsService.saveHistriPelayananCs(hpcsvo);
|
|
||||||
if (result != null)
|
|
||||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
|
|
||||||
return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage);
|
|
||||||
|
|
||||||
|
@RequestMapping(value = "/save-histori-pelayanancs", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
|
||||||
|
public ResponseEntity<Map<String, Object>> saveHistoriPelayananCs(@Valid @RequestBody HistoriPelayananCsVO hpcsvo,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
try {
|
||||||
|
Map<String, Object> result = this.historiPelayananCsService.saveHistriPelayananCs(hpcsvo);
|
||||||
|
if (result != null)
|
||||||
|
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||||
|
return getJsonResponse(result, CREATED, mapHeaderMessage);
|
||||||
} catch (ServiceVOException e) {
|
} catch (ServiceVOException e) {
|
||||||
|
LOGGER.error("Got ServiceVOException {} when saveHistriPelayananCs", e.getMessage());
|
||||||
LOGGER.error("Got exception {} when saveHistoriPelayananCs", e.getMessage());
|
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
|
||||||
|
|
||||||
} catch (JpaSystemException jse) {
|
} catch (JpaSystemException jse) {
|
||||||
|
LOGGER.error("Got JpaSystemException {} when saveHistriPelayananCs", jse.getMessage());
|
||||||
LOGGER.error("Got exception {} when saveHistoriPelayananCs", jse.getMessage());
|
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(
|
@RequestMapping(value = "/get-list-histori-pelayanan", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||||
value = "/get-list-histori-pelayanan",
|
|
||||||
method = RequestMethod.GET,
|
|
||||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
public ResponseEntity<Map<String, Object>> getListHistoriPelayanan(
|
public ResponseEntity<Map<String, Object>> getListHistoriPelayanan(
|
||||||
@RequestParam(value = "ruanganId", required = true) Integer ruanganId, HttpServletRequest request){
|
@RequestParam(value = "ruanganId") Integer ruanganId, HttpServletRequest request) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Map<String,Object> result = this.historiPelayananCsService.getListHistoriPelayananCs(ruanganId);
|
Map<String, Object> result = this.historiPelayananCsService.getListHistoriPelayananCs(ruanganId);
|
||||||
|
if (null != result) {
|
||||||
if (null != result){
|
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
|
return getJsonResponse(result, OK, mapHeaderMessage);
|
||||||
return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage);
|
} else {
|
||||||
|
return getJsonResponse(null, NOT_FOUND, mapHeaderMessage);
|
||||||
} else{
|
|
||||||
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (ServiceVOException e) {
|
} catch (ServiceVOException e) {
|
||||||
LOGGER.error("Got exception {} when getListHistoriPelayanan", e.getMessage());
|
LOGGER.error("Got ServiceVOException {} when getListHistoriPelayananCs", e.getMessage());
|
||||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||||
|
|
||||||
} catch (JpaSystemException jse) {
|
} catch (JpaSystemException jse) {
|
||||||
LOGGER.error("Got exception {} when getListHistoriPelayanan", jse.getMessage());
|
LOGGER.error("Got JpaSystemException {} when getListHistoriPelayananCs", jse.getMessage());
|
||||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(
|
@RequestMapping(value = "/get-load-histori-pelayanan", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||||
value = "/get-load-histori-pelayanan",
|
public ResponseEntity<Map<String, Object>> getLoadData(@RequestParam(value = "ruanganId") Integer ruanganId,
|
||||||
method = RequestMethod.GET,
|
HttpServletRequest request) {
|
||||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
public ResponseEntity<Map<String, Object>> getLoadData(
|
|
||||||
@RequestParam(value = "ruanganId", required = true) Integer ruanganId, HttpServletRequest request){
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Map<String,Object> result = this.historiPelayananCsService.getLoadData(ruanganId);
|
Map<String, Object> result = this.historiPelayananCsService.getLoadData(ruanganId);
|
||||||
|
if (null != result) {
|
||||||
if (null != result){
|
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
|
return getJsonResponse(result, OK, mapHeaderMessage);
|
||||||
return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage);
|
} else {
|
||||||
} else{
|
return getJsonResponse(null, NOT_FOUND, mapHeaderMessage);
|
||||||
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (ServiceVOException e) {
|
} catch (ServiceVOException e) {
|
||||||
LOGGER.error("Got exception {} when getLoadData", e.getMessage());
|
LOGGER.error("Got ServiceVOException {} when getLoadData", e.getMessage());
|
||||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||||
|
|
||||||
} catch (JpaSystemException jse) {
|
} catch (JpaSystemException jse) {
|
||||||
LOGGER.error("Got exception {} when getLoadData", jse.getMessage());
|
LOGGER.error("Got JpaSystemException {} when getLoadData", jse.getMessage());
|
||||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(
|
@RequestMapping(value = "/get-load-pasien-bynocm", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||||
value = "/get-load-pasien-bynocm",
|
public ResponseEntity<Map<String, Object>> getDataPasienByNoCm(@RequestParam(value = "noCm") String noCm,
|
||||||
method = RequestMethod.GET,
|
HttpServletRequest request) {
|
||||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
try {
|
||||||
public ResponseEntity<Map<String, Object>> getDataPasienByNoCm(
|
Map<String, Object> result = this.historiPelayananCsService.getListPasienByNoCm(noCm);
|
||||||
@RequestParam(value = "noCm", required = true) String noCm, HttpServletRequest request){
|
if (null != result) {
|
||||||
|
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||||
try {
|
return getJsonResponse(result, OK, mapHeaderMessage);
|
||||||
Map<String,Object> result = this.historiPelayananCsService.getListPasienByNoCm(noCm);
|
} else {
|
||||||
|
return getJsonResponse(null, NOT_FOUND, mapHeaderMessage);
|
||||||
if (null != result){
|
|
||||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
|
|
||||||
return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage);
|
|
||||||
} else{
|
|
||||||
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (ServiceVOException e) {
|
|
||||||
LOGGER.error("Got exception {} when getLoadData", e.getMessage());
|
|
||||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
|
||||||
|
|
||||||
} catch (JpaSystemException jse) {
|
|
||||||
LOGGER.error("Got exception {} when getLoadData", jse.getMessage());
|
|
||||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
} catch (ServiceVOException e) {
|
||||||
|
LOGGER.error("Got ServiceVOException {} when getListPasienByNoCm", e.getMessage());
|
||||||
|
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||||
|
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||||
|
} catch (JpaSystemException jse) {
|
||||||
|
LOGGER.error("Got JpaSystemException {} when getListPasienByNoCm", jse.getMessage());
|
||||||
|
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||||
|
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@RequestMapping(
|
|
||||||
value = "/get-load-produk-informasi",
|
@RequestMapping(value = "/get-load-produk-informasi", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||||
method = RequestMethod.GET,
|
public ResponseEntity<Map<String, Object>> getDataProdukInformasi(HttpServletRequest request) {
|
||||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
try {
|
||||||
public ResponseEntity<Map<String, Object>> getDataProdukInformasi(
|
Map<String, Object> result = this.historiPelayananCsService.getListProdukInformasi();
|
||||||
HttpServletRequest request){
|
if (null != result) {
|
||||||
|
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||||
try {
|
return getJsonResponse(result, OK, mapHeaderMessage);
|
||||||
Map<String,Object> result = this.historiPelayananCsService.getListProdukInformasi();
|
} else {
|
||||||
|
return getJsonResponse(null, NOT_FOUND, mapHeaderMessage);
|
||||||
if (null != result){
|
|
||||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
|
|
||||||
return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage);
|
|
||||||
} else{
|
|
||||||
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (ServiceVOException e) {
|
|
||||||
LOGGER.error("Got exception {} when getLoadData", e.getMessage());
|
|
||||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
|
||||||
|
|
||||||
} catch (JpaSystemException jse) {
|
|
||||||
LOGGER.error("Got exception {} when getLoadData", jse.getMessage());
|
|
||||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
} catch (ServiceVOException e) {
|
||||||
|
LOGGER.error("Got ServiceVOException {} when getListProdukInformasi", e.getMessage());
|
||||||
|
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||||
|
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||||
|
} catch (JpaSystemException jse) {
|
||||||
|
LOGGER.error("Got JpaSystemException {} when getListProdukInformasi", jse.getMessage());
|
||||||
|
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||||
|
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@RequestMapping(
|
|
||||||
value = "/get-histori-pelayanan-norec/{norec}",
|
@RequestMapping(value = "/get-histori-pelayanan-norec/{norec}", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||||
method = RequestMethod.GET,
|
public ResponseEntity<Map<String, Object>> getDataHistoriCsByNoRec(@PathVariable(value = "norec") String norec,
|
||||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
HttpServletRequest request) {
|
||||||
public ResponseEntity<Map<String, Object>> getDataHistoriCsByNoRec(
|
try {
|
||||||
@PathVariable(value = "norec") String norec, HttpServletRequest request){
|
Map<String, Object> result = this.historiPelayananCsService.getListHistoriCsByNorec(norec);
|
||||||
|
if (null != result) {
|
||||||
try {
|
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||||
Map<String,Object> result = this.historiPelayananCsService.getListHistoriCsByNorec(norec);
|
return getJsonResponse(result, OK, mapHeaderMessage);
|
||||||
|
} else {
|
||||||
if (null != result){
|
return getJsonResponse(null, NOT_FOUND, mapHeaderMessage);
|
||||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
|
|
||||||
return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage);
|
|
||||||
} else{
|
|
||||||
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (ServiceVOException e) {
|
|
||||||
LOGGER.error("Got exception {} when getLoadData", e.getMessage());
|
|
||||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
|
||||||
|
|
||||||
} catch (JpaSystemException jse) {
|
|
||||||
LOGGER.error("Got exception {} when getLoadData", jse.getMessage());
|
|
||||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
} catch (ServiceVOException e) {
|
||||||
|
LOGGER.error("Got ServiceVOException {} when getListHistoriCsByNorec", e.getMessage());
|
||||||
|
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||||
|
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||||
|
} catch (JpaSystemException jse) {
|
||||||
|
LOGGER.error("Got JpaSystemException {} when getListHistoriCsByNorec", jse.getMessage());
|
||||||
|
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||||
|
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,68 +1,47 @@
|
|||||||
package com.jasamedika.medifirst2000.controller;
|
package com.jasamedika.medifirst2000.controller;
|
||||||
|
|
||||||
import java.util.Map;
|
import com.jasamedika.medifirst2000.entities.HistoryLoginModulAplikasi;
|
||||||
|
import com.jasamedika.medifirst2000.entities.HistoryLoginUser;
|
||||||
|
import com.jasamedika.medifirst2000.service.HistoryLoginModulAplikasiService;
|
||||||
|
import com.jasamedika.medifirst2000.service.HistoryLoginUserService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
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.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import com.jasamedika.medifirst2000.service.HistoryLoginModulAplikasiService;
|
import java.util.Map;
|
||||||
import com.jasamedika.medifirst2000.service.HistoryLoginUserService;
|
|
||||||
import com.jasamedika.medifirst2000.util.rest.RestUtil;
|
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
|
||||||
|
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;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* @author Syamsu
|
* @author Syamsu
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping({"/test-tanpa-auth/logging", "/logging"})
|
@RequestMapping("/logging")
|
||||||
public class HistoryLoggingController {
|
public class HistoryLoggingController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
HistoryLoginUserService historyLoginUserService;
|
HistoryLoginUserService<HistoryLoginUser> historyLoginUserService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
HistoryLoginModulAplikasiService historyLoginModulAplikasiService;
|
HistoryLoginModulAplikasiService<HistoryLoginModulAplikasi> historyLoginModulAplikasiService;
|
||||||
|
|
||||||
@RequestMapping(value = "/get-all-history-login-on-modul", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(value = "/get-all-history-login-on-modul", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||||
public ResponseEntity<Map<String, Object>> getAllHistoryModulAplikasi(
|
public ResponseEntity<Map<String, Object>> getAllHistoryModulAplikasi(@RequestParam("kdUser") String kdUser) {
|
||||||
@RequestParam("kdUser") String kdUser){
|
|
||||||
Map<String, Object> hasil = historyLoginModulAplikasiService.findByHistoryLoginModulAplikasi(kdUser);
|
Map<String, Object> hasil = historyLoginModulAplikasiService.findByHistoryLoginModulAplikasi(kdUser);
|
||||||
return RestUtil.getJsonResponse(hasil, HttpStatus.OK);
|
return getJsonResponse(hasil, OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/get-page-history-login-on-modul", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(value = "/get-all-history-login-activity", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||||
public ResponseEntity<Map<String, Object>> getPageHistoryModulAplikasi(
|
|
||||||
@RequestParam("kdUser") String kdUser,
|
|
||||||
@RequestParam("page") Integer page,
|
|
||||||
@RequestParam("limit") Integer limit,
|
|
||||||
@RequestParam("sort") String sort,
|
|
||||||
@RequestParam("dir") String dir){
|
|
||||||
Map<String, Object> hasil = historyLoginModulAplikasiService.findByHistoryLoginModulAplikasi(kdUser, page, limit, sort, dir);
|
|
||||||
return RestUtil.getJsonResponse(hasil, HttpStatus.OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping(value = "/get-all-history-login-activity", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
public ResponseEntity<Map<String, Object>> getAllHistoryLogin(
|
public ResponseEntity<Map<String, Object>> getAllHistoryLogin(
|
||||||
@RequestParam("kdHistoryLogin") Integer kdHistoryLogin){
|
@RequestParam("kdHistoryLogin") Integer kdHistoryLogin) {
|
||||||
Map<String, Object> hasil = historyLoginUserService.findByHistoryLoginId(kdHistoryLogin);
|
Map<String, Object> hasil = historyLoginUserService.findByHistoryLoginId(kdHistoryLogin);
|
||||||
return RestUtil.getJsonResponse(hasil, HttpStatus.OK);
|
return getJsonResponse(hasil, OK);
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "/get-page-history-login-activity", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
public ResponseEntity<Map<String, Object>> getPageHistoryLogin(
|
|
||||||
@RequestParam("kdHistoryLogin") Integer kdHistoryLogin,
|
|
||||||
@RequestParam("page") Integer page,
|
|
||||||
@RequestParam("limit") Integer limit,
|
|
||||||
@RequestParam("sort") String sort,
|
|
||||||
@RequestParam("dir") String dir){
|
|
||||||
Map<String, Object> hasil = historyLoginUserService.findByHistoryLoginId(kdHistoryLogin, page, limit, sort, dir);
|
|
||||||
return RestUtil.getJsonResponse(hasil, HttpStatus.OK);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,269 +0,0 @@
|
|||||||
package com.jasamedika.medifirst2000.controller;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.orm.jpa.JpaSystemException;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
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 com.itextpdf.text.BadElementException;
|
|
||||||
import com.itextpdf.text.Document;
|
|
||||||
import com.itextpdf.text.DocumentException;
|
|
||||||
import com.itextpdf.text.Image;
|
|
||||||
import com.itextpdf.text.PageSize;
|
|
||||||
import com.itextpdf.text.pdf.PdfWriter;
|
|
||||||
import com.itextpdf.text.pdf.codec.Base64;
|
|
||||||
import com.itextpdf.tool.xml.XMLWorker;
|
|
||||||
import com.itextpdf.tool.xml.XMLWorkerHelper;
|
|
||||||
import com.itextpdf.tool.xml.html.Tags;
|
|
||||||
import com.itextpdf.tool.xml.parser.XMLParser;
|
|
||||||
import com.itextpdf.tool.xml.pipeline.css.CSSResolver;
|
|
||||||
import com.itextpdf.tool.xml.pipeline.css.CssResolverPipeline;
|
|
||||||
import com.itextpdf.tool.xml.pipeline.end.PdfWriterPipeline;
|
|
||||||
import com.itextpdf.tool.xml.pipeline.html.AbstractImageProvider;
|
|
||||||
import com.itextpdf.tool.xml.pipeline.html.HtmlPipeline;
|
|
||||||
import com.itextpdf.tool.xml.pipeline.html.HtmlPipelineContext;
|
|
||||||
import com.jasamedika.medifirst2000.constants.Constants;
|
|
||||||
import com.jasamedika.medifirst2000.controller.base.LocaleController;
|
|
||||||
import com.jasamedika.medifirst2000.exception.ServiceVOException;
|
|
||||||
import com.jasamedika.medifirst2000.util.rest.RestUtil;
|
|
||||||
import com.jasamedika.medifirst2000.vo.PemakaianAsuransiVO;
|
|
||||||
|
|
||||||
class Base64ImageProvider extends AbstractImageProvider {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Image retrieve(String src) {
|
|
||||||
int pos = src.indexOf("base64,");
|
|
||||||
try {
|
|
||||||
if (src.startsWith("data") && pos > 0) {
|
|
||||||
byte[] img = Base64.decode(src.substring(pos + 7));
|
|
||||||
return Image.getInstance(img);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
return Image.getInstance(src);
|
|
||||||
}
|
|
||||||
} catch (BadElementException ex) {
|
|
||||||
return null;
|
|
||||||
} catch (IOException ex) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getImageRootPath() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/html-to-pdf")
|
|
||||||
public class HtmlToPdfController extends LocaleController {
|
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(HtmlToPdfController.class);
|
|
||||||
|
|
||||||
@RequestMapping(value = "/get-pdf", method = RequestMethod.GET)
|
|
||||||
public ResponseEntity<String> getAllVOWithQueryString(HttpServletRequest request, HttpServletResponse response,
|
|
||||||
@RequestParam(value = "url") String url, @RequestParam(value = "fileName") String fileName) {
|
|
||||||
|
|
||||||
try {
|
|
||||||
createPDF(fileName, url, request, response);
|
|
||||||
return RestUtil.getJsonResponse("", HttpStatus.CREATED, mapHeaderMessage);
|
|
||||||
} catch (ServiceVOException e) {
|
|
||||||
LOGGER.error("Got exception {} when add Agama", e.getMessage());
|
|
||||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
|
||||||
} catch (JpaSystemException jse) {
|
|
||||||
LOGGER.error("Got exception {} when add Agama", jse.getMessage());
|
|
||||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "/post-pdf", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
public ResponseEntity<String> postPdf(HttpServletRequest request, HttpServletResponse response,
|
|
||||||
@RequestParam(value = "url") String url, @RequestParam(value = "fileName") String fileName) {
|
|
||||||
|
|
||||||
try {
|
|
||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(request.getInputStream()));
|
|
||||||
|
|
||||||
String read = null;
|
|
||||||
String resultData = "";
|
|
||||||
while ((read = reader.readLine()) != null) {
|
|
||||||
resultData += read;
|
|
||||||
System.out.println(read);
|
|
||||||
}
|
|
||||||
InputStream is = new ByteArrayInputStream(resultData.getBytes());
|
|
||||||
createPDF(fileName, url, resultData, request, response);
|
|
||||||
return RestUtil.getJsonResponse("", HttpStatus.CREATED, mapHeaderMessage);
|
|
||||||
} catch (ServiceVOException e) {
|
|
||||||
LOGGER.error("Got exception {} when add Agama", e.getMessage());
|
|
||||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
|
||||||
} catch (JpaSystemException jse) {
|
|
||||||
LOGGER.error("Got exception {} when add Agama", jse.getMessage());
|
|
||||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createPDF(String pdfFilename, String url, HttpServletRequest request, HttpServletResponse response) {
|
|
||||||
|
|
||||||
// path for the PDF file to be generated
|
|
||||||
String dataDirectory = request.getServletContext().getRealPath("/WEB-INF/downloads/pdf/" + pdfFilename);
|
|
||||||
PdfWriter pdfWriter = null;
|
|
||||||
|
|
||||||
// create a new document
|
|
||||||
Document document = new Document();
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
// get Instance of the PDFWriter
|
|
||||||
pdfWriter = PdfWriter.getInstance(document, new FileOutputStream(dataDirectory));
|
|
||||||
|
|
||||||
// document header attributes
|
|
||||||
document.addAuthor("betterThanZero");
|
|
||||||
document.addCreationDate();
|
|
||||||
document.addProducer();
|
|
||||||
document.addCreator("MySampleCode.com");
|
|
||||||
document.addTitle("Demo for iText XMLWorker");
|
|
||||||
document.setPageSize(PageSize.LETTER);
|
|
||||||
|
|
||||||
// open document
|
|
||||||
document.open();
|
|
||||||
|
|
||||||
// To convert a HTML file from the filesystem
|
|
||||||
// String File_To_Convert = "docs/SamplePDF.html";
|
|
||||||
// FileInputStream fis = new FileInputStream(File_To_Convert);
|
|
||||||
|
|
||||||
// URL for HTML page
|
|
||||||
URL myWebPage = new URL(url);
|
|
||||||
InputStreamReader fis = new InputStreamReader(myWebPage.openStream());
|
|
||||||
|
|
||||||
// get the XMLWorkerHelper Instance
|
|
||||||
XMLWorkerHelper worker = XMLWorkerHelper.getInstance();
|
|
||||||
|
|
||||||
// convert to PDF
|
|
||||||
worker.parseXHtml(pdfWriter, document, fis);
|
|
||||||
|
|
||||||
// close the document
|
|
||||||
document.close();
|
|
||||||
// close the writer
|
|
||||||
pdfWriter.close();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
catch (FileNotFoundException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (DocumentException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
String dataDirectoryDownload = request.getServletContext().getRealPath("/WEB-INF/downloads/pdf/");
|
|
||||||
Path file = Paths.get(dataDirectoryDownload, pdfFilename);
|
|
||||||
if (Files.exists(file)) {
|
|
||||||
response.setContentType("application/pdf");
|
|
||||||
response.addHeader("Content-Disposition", "attachment; filename=" + pdfFilename);
|
|
||||||
try {
|
|
||||||
Files.copy(file, response.getOutputStream());
|
|
||||||
response.getOutputStream().flush();
|
|
||||||
} catch (IOException ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createPDF(String pdfFilename, String url, String inputStream, HttpServletRequest request,
|
|
||||||
HttpServletResponse response) {
|
|
||||||
|
|
||||||
// path for the PDF file to be generated
|
|
||||||
String dataDirectory = request.getServletContext().getRealPath("/WEB-INF/downloads/pdf/" + pdfFilename);
|
|
||||||
PdfWriter pdfWriter = null;
|
|
||||||
|
|
||||||
// create a new document
|
|
||||||
Document document = new Document();
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
|
|
||||||
// step 2
|
|
||||||
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(dataDirectory));
|
|
||||||
// step 3
|
|
||||||
document.open();
|
|
||||||
// step 4
|
|
||||||
|
|
||||||
// CSS
|
|
||||||
CSSResolver cssResolver =
|
|
||||||
XMLWorkerHelper.getInstance().getDefaultCssResolver(true);
|
|
||||||
|
|
||||||
// HTML
|
|
||||||
HtmlPipelineContext htmlContext = new HtmlPipelineContext(null);
|
|
||||||
htmlContext.setTagFactory(Tags.getHtmlTagProcessorFactory());
|
|
||||||
htmlContext.setImageProvider(new Base64ImageProvider());
|
|
||||||
|
|
||||||
// Pipelines
|
|
||||||
PdfWriterPipeline pdf = new PdfWriterPipeline(document, writer);
|
|
||||||
HtmlPipeline html = new HtmlPipeline(htmlContext, pdf);
|
|
||||||
CssResolverPipeline css = new CssResolverPipeline(cssResolver, html);
|
|
||||||
|
|
||||||
// XML Worker
|
|
||||||
XMLWorker worker = new XMLWorker(css, true);
|
|
||||||
XMLParser p = new XMLParser(worker);
|
|
||||||
p.parse(new ByteArrayInputStream(inputStream.getBytes()));
|
|
||||||
|
|
||||||
// step 5
|
|
||||||
document.close();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
catch (FileNotFoundException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (DocumentException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
String dataDirectoryDownload = request.getServletContext().getRealPath("/WEB-INF/downloads/pdf/");
|
|
||||||
Path file = Paths.get(dataDirectoryDownload, pdfFilename);
|
|
||||||
if (Files.exists(file)) {
|
|
||||||
response.setContentType("application/pdf");
|
|
||||||
response.addHeader("Content-Disposition", "attachment; filename=" + pdfFilename);
|
|
||||||
try {
|
|
||||||
Files.copy(file, response.getOutputStream());
|
|
||||||
response.getOutputStream().flush();
|
|
||||||
} catch (IOException ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,197 +1,157 @@
|
|||||||
package com.jasamedika.medifirst2000.controller;
|
package com.jasamedika.medifirst2000.controller;
|
||||||
|
|
||||||
import java.text.ParseException;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.validation.Valid;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.orm.jpa.JpaSystemException;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
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 com.jasamedika.medifirst2000.constants.Constants;
|
|
||||||
import com.jasamedika.medifirst2000.constants.MessageResource;
|
import com.jasamedika.medifirst2000.constants.MessageResource;
|
||||||
import com.jasamedika.medifirst2000.controller.base.LocaleController;
|
import com.jasamedika.medifirst2000.controller.base.LocaleController;
|
||||||
import com.jasamedika.medifirst2000.core.web.WebConstants;
|
|
||||||
import com.jasamedika.medifirst2000.exception.ServiceVOException;
|
import com.jasamedika.medifirst2000.exception.ServiceVOException;
|
||||||
import com.jasamedika.medifirst2000.service.IkiDanRemunerasiService;
|
import com.jasamedika.medifirst2000.service.IkiDanRemunerasiService;
|
||||||
import com.jasamedika.medifirst2000.util.rest.RestUtil;
|
|
||||||
import com.jasamedika.medifirst2000.vo.IkiDanRemunerasiVO;
|
import com.jasamedika.medifirst2000.vo.IkiDanRemunerasiVO;
|
||||||
import com.jasamedika.medifirst2000.vo.SettingPirSdmVO;
|
import com.jasamedika.medifirst2000.vo.SettingPirSdmVO;
|
||||||
import com.jasamedika.medifirst2000.vo.StrukHistoriVO;
|
import com.jasamedika.medifirst2000.vo.StrukHistoriVO;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.orm.jpa.JpaSystemException;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static com.jasamedika.medifirst2000.constants.Constants.MessageInfo.ERROR_MESSAGE;
|
||||||
|
import static com.jasamedika.medifirst2000.core.web.WebConstants.HttpHeaderInfo.LABEL_SUCCESS;
|
||||||
|
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonHttpStatus;
|
||||||
|
import static com.jasamedika.medifirst2000.util.rest.RestUtil.getJsonResponse;
|
||||||
|
import static org.springframework.http.HttpStatus.*;
|
||||||
|
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
|
||||||
|
import static org.springframework.web.bind.annotation.RequestMethod.GET;
|
||||||
|
import static org.springframework.web.bind.annotation.RequestMethod.POST;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/iki-remunerasi")
|
@RequestMapping("/iki-remunerasi")
|
||||||
public class IkiDanRemunerasiController extends LocaleController<IkiDanRemunerasiVO>{
|
public class IkiDanRemunerasiController extends LocaleController<IkiDanRemunerasiVO> {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(IkiDanRemunerasiController.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IkiDanRemunerasiService service;
|
private IkiDanRemunerasiService service;
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(IkiDanRemunerasiController.class);
|
|
||||||
|
|
||||||
@RequestMapping(value = "/get-load-data", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
public ResponseEntity<Map<String, Object>> getLoadData(HttpServletRequest request) {
|
|
||||||
try {
|
|
||||||
Map<String,Object> result = service.loadData();
|
|
||||||
if (null != result){
|
|
||||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
|
|
||||||
return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage);
|
|
||||||
} else{
|
|
||||||
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage);
|
|
||||||
}
|
|
||||||
} catch (ServiceVOException e) {
|
|
||||||
LOGGER.error("Got exception {} when getLoadData", e.getMessage());
|
|
||||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
|
||||||
} catch (JpaSystemException jse) {
|
|
||||||
LOGGER.error("Got exception {} when getLoadData", jse.getMessage());
|
|
||||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "/get-kalkulasi-remunerasi", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
public ResponseEntity<Map<String, Object>> getKalkulasiDataRemunerasi(
|
|
||||||
@RequestParam(value = "id", required = true) Integer id,
|
|
||||||
@RequestParam(value = "date", required = true) String date, HttpServletRequest request) {
|
|
||||||
try {
|
|
||||||
Map<String,Object> result = service.getKalkulasiDataRemunerasi(id, date);
|
|
||||||
if (null != result){
|
|
||||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
|
|
||||||
return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage);
|
|
||||||
} else{
|
|
||||||
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage);
|
|
||||||
}
|
|
||||||
} catch (ServiceVOException e) {
|
|
||||||
LOGGER.error("Got exception {} when getKalkulasiDataRemunerasi", e.getMessage());
|
|
||||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
|
||||||
} catch (JpaSystemException jse) {
|
|
||||||
LOGGER.error("Got exception {} when getKalkulasiDataRemunerasi", jse.getMessage());
|
|
||||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "/save-iki-remunerasi", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
public ResponseEntity<Map<String,Object>> saveIkiRemunerasi(@Valid @RequestBody StrukHistoriVO vo,HttpServletRequest request) {
|
|
||||||
try {
|
|
||||||
Map<String,Object> result = service.saveIkiRemunerasi(vo);
|
|
||||||
if (null != result)
|
|
||||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
|
|
||||||
return RestUtil.getJsonResponse(result, HttpStatus.CREATED,mapHeaderMessage);
|
|
||||||
|
|
||||||
} catch (ServiceVOException e) {
|
@RequestMapping(value = "/get-kalkulasi-remunerasi", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||||
LOGGER.error("Got exception {} when saveIkiRemunerasi", e.getMessage());
|
public ResponseEntity<Map<String, Object>> getKalkulasiDataRemunerasi(@RequestParam(value = "id") Integer id,
|
||||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
@RequestParam(value = "date") String date, HttpServletRequest request) {
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
|
||||||
} catch (JpaSystemException jse) {
|
|
||||||
LOGGER.error("Got exception {} when saveIkiRemunerasi", jse.getMessage());
|
|
||||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "/get-kalkulasi-remunerasi-pegawai", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
public ResponseEntity<Map<String, Object>> getKalkulasiDataRemunerasiPegawai(
|
|
||||||
@RequestParam(value = "date", required = true) String date, HttpServletRequest request) {
|
|
||||||
try {
|
try {
|
||||||
Map<String,Object> result = service.getKalkulasiDataRemunerasiPegawai(date);
|
Map<String, Object> result = service.getKalkulasiDataRemunerasi(id, date);
|
||||||
if (null != result){
|
if (null != result) {
|
||||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,getMessage(MessageResource.LABEL_SUCCESS,request));
|
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||||
return RestUtil.getJsonResponse(result, HttpStatus.OK,mapHeaderMessage);
|
return getJsonResponse(result, OK, mapHeaderMessage);
|
||||||
} else{
|
} else {
|
||||||
return RestUtil.getJsonResponse(result, HttpStatus.NOT_FOUND,mapHeaderMessage);
|
return getJsonResponse(null, NOT_FOUND, mapHeaderMessage);
|
||||||
}
|
}
|
||||||
} catch (ServiceVOException e) {
|
} catch (ServiceVOException e) {
|
||||||
LOGGER.error("Got exception {} when getKalkulasiDataRemunerasi", e.getMessage());
|
LOGGER.error("Got ServiceVOException {} when getKalkulasiDataRemunerasi", e.getMessage());
|
||||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||||
} catch (JpaSystemException jse) {
|
} catch (JpaSystemException jse) {
|
||||||
LOGGER.error("Got exception {} when getKalkulasiDataRemunerasi", jse.getMessage());
|
LOGGER.error("Got JpaSystemException {} when getKalkulasiDataRemunerasi", jse.getMessage());
|
||||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "/save-iki-remunerasi", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
|
||||||
@RequestMapping(value = "/get-pir/{tahun}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
public ResponseEntity<Map<String, Object>> saveIkiRemunerasi(@Valid @RequestBody StrukHistoriVO vo,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
try {
|
||||||
|
Map<String, Object> result = service.saveIkiRemunerasi(vo);
|
||||||
|
if (null != result)
|
||||||
|
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||||
|
return getJsonResponse(result, CREATED, mapHeaderMessage);
|
||||||
|
} catch (ServiceVOException e) {
|
||||||
|
LOGGER.error("Got ServiceVOException {} when saveIkiRemunerasi", e.getMessage());
|
||||||
|
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||||
|
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||||
|
} catch (JpaSystemException jse) {
|
||||||
|
LOGGER.error("Got JpaSystemException {} when saveIkiRemunerasi", jse.getMessage());
|
||||||
|
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||||
|
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "/get-kalkulasi-remunerasi-pegawai", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||||
|
public ResponseEntity<Map<String, Object>> getKalkulasiDataRemunerasiPegawai(
|
||||||
|
@RequestParam(value = "date") String date, HttpServletRequest request) {
|
||||||
|
try {
|
||||||
|
Map<String, Object> result = service.getKalkulasiDataRemunerasiPegawai(date);
|
||||||
|
if (null != result) {
|
||||||
|
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||||
|
return getJsonResponse(result, OK, mapHeaderMessage);
|
||||||
|
} else {
|
||||||
|
return getJsonResponse(null, NOT_FOUND, mapHeaderMessage);
|
||||||
|
}
|
||||||
|
} catch (ServiceVOException e) {
|
||||||
|
LOGGER.error("Got ServiceVOException {} when getKalkulasiDataRemunerasiPegawai", e.getMessage());
|
||||||
|
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||||
|
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||||
|
} catch (JpaSystemException jse) {
|
||||||
|
LOGGER.error("Got JpaSystemException {} when getKalkulasiDataRemunerasiPegawai", jse.getMessage());
|
||||||
|
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||||
|
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "/get-pir/{tahun}", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||||
public ResponseEntity<Map<String, Object>> findPir(@PathVariable("tahun") String tahun,
|
public ResponseEntity<Map<String, Object>> findPir(@PathVariable("tahun") String tahun,
|
||||||
HttpServletRequest request) {
|
HttpServletRequest request) {
|
||||||
Map<String, Object> result = null;
|
|
||||||
try {
|
try {
|
||||||
|
Map<String, Object> result = service.findPir(tahun);
|
||||||
result = service.findPir(tahun);
|
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
|
return getJsonResponse(result, OK);
|
||||||
getMessage(MessageResource.LABEL_SUCCESS, request));
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
throw new ServiceVOException(e.getMessage());
|
||||||
}
|
}
|
||||||
return RestUtil.getJsonResponse(result, HttpStatus.OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "/get-iku/{periode}/{idUnitKerja}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
public ResponseEntity<Map<String, Object>> findPir(@PathVariable("periode") String periode,@PathVariable("idUnitKerja") Integer idUnitKerja,
|
|
||||||
HttpServletRequest request) {
|
|
||||||
Map<String, Object> result = null;
|
|
||||||
try {
|
|
||||||
|
|
||||||
result = service.findIKU(periode,idUnitKerja);
|
|
||||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
|
|
||||||
getMessage(MessageResource.LABEL_SUCCESS, request));
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return RestUtil.getJsonResponse(result, HttpStatus.OK);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/get-all-iku/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(value = "/get-iku/{periode}/{idUnitKerja}", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||||
public ResponseEntity<List<Map<String, Object>>> findPir(
|
public ResponseEntity<Map<String, Object>> findPir(@PathVariable("periode") String periode,
|
||||||
HttpServletRequest request) {
|
@PathVariable("idUnitKerja") Integer idUnitKerja, HttpServletRequest request) {
|
||||||
List<Map<String, Object>> result = null;
|
|
||||||
try {
|
try {
|
||||||
|
Map<String, Object> result = service.findIKU(periode, idUnitKerja);
|
||||||
result = service.findAllIKU();
|
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
|
return getJsonResponse(result, OK);
|
||||||
getMessage(MessageResource.LABEL_SUCCESS, request));
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
throw new ServiceVOException(e.getMessage());
|
||||||
}
|
}
|
||||||
return RestUtil.getJsonResponse(result, HttpStatus.OK);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/save-pir-dan-iku", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(value = "/get-all-iku/", method = GET, produces = APPLICATION_JSON_VALUE)
|
||||||
|
public ResponseEntity<List<Map<String, Object>>> findPir(HttpServletRequest request) {
|
||||||
|
try {
|
||||||
|
List<Map<String, Object>> result = service.findAllIKU();
|
||||||
|
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||||
|
return getJsonResponse(result, OK);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new ServiceVOException(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "/save-pir-dan-iku", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
|
||||||
public ResponseEntity<Map<String, Object>> savePirDanIku(@Valid @RequestBody List<SettingPirSdmVO> vo,
|
public ResponseEntity<Map<String, Object>> savePirDanIku(@Valid @RequestBody List<SettingPirSdmVO> vo,
|
||||||
HttpServletRequest request) throws ParseException {
|
HttpServletRequest request) {
|
||||||
try {
|
try {
|
||||||
Map<String, Object> result = service.savePirDanIku(vo);
|
Map<String, Object> result = service.savePirDanIku(vo);
|
||||||
if (null != result)
|
if (null != result)
|
||||||
mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
|
mapHeaderMessage.put(LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
|
||||||
getMessage(MessageResource.LABEL_SUCCESS, request));
|
return getJsonResponse(result, CREATED, mapHeaderMessage);
|
||||||
return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
|
|
||||||
|
|
||||||
} catch (ServiceVOException e) {
|
} catch (ServiceVOException e) {
|
||||||
LOGGER.error("Got exception {} when add Pegawai Jadwal kerja", e.getMessage());
|
LOGGER.error("Got ServiceVOException {} when savePirDanIku", e.getMessage());
|
||||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, e.getMessage());
|
addHeaderMessage(ERROR_MESSAGE, e.getMessage());
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
return getJsonHttpStatus(INTERNAL_SERVER_ERROR, mapHeaderMessage);
|
||||||
} catch (JpaSystemException jse) {
|
} catch (JpaSystemException jse) {
|
||||||
LOGGER.error("Got exception {} when add Pegawai Jadwal kerja", jse.getMessage());
|
LOGGER.error("Got JpaSystemException {} when savePirDanIku", jse.getMessage());
|
||||||
addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
|
addHeaderMessage(ERROR_MESSAGE, jse.getMessage());
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
|
return getJsonHttpStatus(CONFLICT, mapHeaderMessage);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user