package com.jasamedika.medifirst2000.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
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.jasamedika.medifirst2000.constants.Constants;
import com.jasamedika.medifirst2000.constants.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.core.web.WebConstants;
import com.jasamedika.medifirst2000.entities.Pegawai;
import com.jasamedika.medifirst2000.entities.Ruangan;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.AkunService;
import com.jasamedika.medifirst2000.service.PsrsPermintaanPerbaikanService;
import com.jasamedika.medifirst2000.service.StokProdukGlobalService;
import com.jasamedika.medifirst2000.service.StrukOrderService;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.AkunVO;
import com.jasamedika.medifirst2000.vo.DistribusiBarangInvestasiVO;
import com.jasamedika.medifirst2000.vo.KirimPerbaikanVO;
import com.jasamedika.medifirst2000.vo.PemeliharaanVO;
import com.jasamedika.medifirst2000.vo.PenjadwalanHeaderVO;
import com.jasamedika.medifirst2000.vo.PerbaikanVO;
import com.jasamedika.medifirst2000.vo.PermintaanPerbaikanVO;
import com.jasamedika.medifirst2000.vo.RequestBarangDariRuanganVO;
import com.jasamedika.medifirst2000.vo.SukuCadangLuarVO;

@RestController
@RequestMapping("/psrsPermintaanPerbaikan")
public class PsrsPermintaanPerbaikanController extends LocaleController<AkunVO>{
	
	@Autowired
	private PsrsPermintaanPerbaikanService psrsPermintaanPerbaikanService;
	
	@Autowired
	private StrukOrderService strukOrderService;
	
	@Autowired
	private StokProdukGlobalService stokProdukGlobalService;
	
	private static final Logger LOGGER = LoggerFactory.getLogger(PsrsPermintaanPerbaikanController.class);
	
	@RequestMapping(value = "/save-permintaan-perbaikan/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<Map<String, Object>> savePermintaanPerbaikan(@Valid @RequestBody PermintaanPerbaikanVO vo,HttpServletRequest request,HttpServletResponse response) {
		
		try {
			Map<String, Object> result = psrsPermintaanPerbaikanService.savePermintaanPerbaikan(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 save Permintaan Perbaikan", 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 save Permintaan Perbaikan", jse.getMessage());
			addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
			return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
		}

	}
	
	@RequestMapping(value = "/get-aset-by-ruangan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> getAsetByRuangan() {
		Map<String, Object> data = psrsPermintaanPerbaikanService.getAsetByRuangan();
		return data;
	}
	
	@RequestMapping(value = "/get-ruangan-by-user-login", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> getRuanganByUserLogin() {
		Ruangan r=psrsPermintaanPerbaikanService.getRuanganByUserLogin();
		Map<String, Object> data = new HashMap<String,Object>();
		data.put("id", r.getId());
		data.put("namaRuangan", r.getNamaRuangan());
		return data;
	}
	
	@RequestMapping(value = "/get-ruangan-tujuan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> getRuanganTujuan() {
		Ruangan r=psrsPermintaanPerbaikanService.getRuanganTujuan();
		Map<String, Object> data = new HashMap<String,Object>();
		data.put("id", r.getId());
		data.put("namaRuangan", r.getNamaRuangan());
		return data;
	}
	
	@RequestMapping(value = "/get-user-login", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> getUserLogin() {
		Pegawai p=psrsPermintaanPerbaikanService.getPegawaiByUserLogin();
		Map<String, Object> data = new HashMap<String,Object>();
		data.put("id", p.getId());
		data.put("namaPegawai", p.getNamaLengkap());
		return data;
	}
	
	
	@RequestMapping(value = "/get-aset-by-produk", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> getAsetByProduk(@RequestParam(value = "produkId") Integer produkId) {
		Map<String, Object> data = psrsPermintaanPerbaikanService.getAsetByProduk(produkId);
		return data;
	}
	
	@RequestMapping(value = "/get-kontrak", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> getKotrak() {
		Map<String, Object> data = psrsPermintaanPerbaikanService.getKotrak();
		return data;
	}
	
	@RequestMapping(value = "/get-kontrak-detail", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> getKontrakDetail(@RequestParam(value = "noRec") String noRec) {
		Map<String, Object> data = psrsPermintaanPerbaikanService.getKontrakDetail(noRec);
		return data;
	}
	
	@RequestMapping(value = "/get-detail-permintaan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> getDetailPermintaan(@RequestParam(value = "noRec") String noRec) {
		Map<String, Object> data = psrsPermintaanPerbaikanService.getDetailPermintaan(noRec);
		return data;
	}
	
	@RequestMapping(value = "/pre-add-perbaikan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> preAddPerbaikan(@RequestParam(value = "noRec") String noRec) {
		Map<String, Object> data = psrsPermintaanPerbaikanService.preAddPerbaikan(noRec);
		return data;
	}
	
	@RequestMapping(value = "/pre-add-pemeliharaan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> preAddPemeliharaan(@RequestParam(value = "noRec") String noRec) {
		Map<String, Object> data = psrsPermintaanPerbaikanService.preAddPemeliharaan(noRec);
		return data;
	}
	
	@RequestMapping(value = "/get-no-order-perbaikan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public Map<String,Object>  getNoPemusnahan() {

		Map<String, Object> result = new HashMap<String,Object>();
		result.put("noOrderPerbaikan", strukOrderService.preFormatNoUrut("Order Perbaikan", "PBK"));
		return result;
	}
	
	@RequestMapping(value = "/get-informasi-perbaikan-masuk", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public Map<String,Object>  informasiPerbaikanMasuk(
				
			@RequestParam(value = "page", required = false, defaultValue = "0") Integer page,
			@RequestParam(value = "take", required = false, defaultValue = "10000") Integer limit,
			@RequestParam(value = "sort", required = false) String sort,
			@RequestParam(value = "dir", required = false, defaultValue = "asc") String dir,
			@RequestParam(value = "dateStart", required = false) String dateStart,
			@RequestParam(value = "dateEnd", required = false) String dateEnd,
			@RequestParam(value = "noOrder", required = false) String noOrder,
			@RequestParam(value = "jenisOrder", required = false) String jenisOrder) {
		Map<String, Object> resultPageMap = strukOrderService.getInformasiPerbaikanMasuk(page, limit, sort, dir, dateStart,dateEnd,noOrder,jenisOrder);
		
		return resultPageMap;
	}

	
	@RequestMapping(value = "/get-informasi-perbaikan-keluar", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public Map<String,Object>  informasiPerbaikanKeluar(
				
			@RequestParam(value = "page", required = false, defaultValue = "0") Integer page,
			@RequestParam(value = "take", required = false, defaultValue = "10000") Integer limit,
			@RequestParam(value = "sort", required = false) String sort,
			@RequestParam(value = "dir", required = false, defaultValue = "asc") String dir,
			@RequestParam(value = "dateStart", required = false) String dateStart,
			@RequestParam(value = "dateEnd", required = false) String dateEnd,
			@RequestParam(value = "noOrder", required = false) String noOrder,
			@RequestParam(value = "jenisOrder", required = false) String jenisOrder) {

		Map<String, Object> resultPageMap = strukOrderService.getInformasiPerbaikanKeluar(page, limit, sort, dir, dateStart,dateEnd,noOrder,jenisOrder);
		
		return resultPageMap;
	}
	
	@RequestMapping(value = "/kirim-perbaikan/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<Map<String, Object>> saveKirimPerbaikan(@Valid @RequestBody KirimPerbaikanVO vo,HttpServletRequest request,HttpServletResponse response) {
		
		
			Map<String, Object> result = psrsPermintaanPerbaikanService.kirimPerbaikan(vo);
			if (null != result)
				mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS,
						getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.CREATED, mapHeaderMessage);
		

	}
	
	@RequestMapping(value = "/save-verifikasi-perbaikan/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<Map<String, Object>> saveVerifikasiPerbaikan(@Valid @RequestBody KirimPerbaikanVO vo,HttpServletRequest request,HttpServletResponse response) {
		
		try {
			Map<String, Object> result = psrsPermintaanPerbaikanService.saveVerifikasiPerbaikan(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 save Penerimaan Barang", 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 save Penerimaan Barang", jse.getMessage());
			addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
			return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
		}

	}
	
	@RequestMapping(value = "/save-penjadwalan/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<Map<String, Object>> savePenjadwalan(@Valid @RequestBody PenjadwalanHeaderVO vo,HttpServletRequest request,HttpServletResponse response) {
		
		try {
			Map<String, Object> result = psrsPermintaanPerbaikanService.savePenjadwalan(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 save Penerimaan Barang", 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 save Penerimaan Barang", jse.getMessage());
			addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
			return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
		}

	}
	
	@RequestMapping(value = "/find-ruangan-asset", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<Map<String, Object>> getRuanganRegistrasiAset(HttpServletRequest request) {
		try {
			Map<String,Object> result = psrsPermintaanPerbaikanService.getRuanganPerbaikan();
			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 getRuanganRegistrasiAset", 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 getRuanganRegistrasiAset", jse.getMessage());
			addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
			return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
		}
	}
	
	@RequestMapping(value = "/find-produk-by-ruangan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<Map<String, Object>> getAsetPerbaikan(@RequestParam(value = "id", required = true) Integer id, HttpServletRequest request){
		try {
			Map<String,Object> result = psrsPermintaanPerbaikanService.getProdukPerbaikan(id);
			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 getAsetPerbaikan", 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 getAsetPerbaikan", jse.getMessage());
			addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
			return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
		}
	}
	
	@RequestMapping(value = "/get-aset-by-produk-and-ruangan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> getAsetByProduk(@RequestParam(value = "produkId") Integer produkId,@RequestParam(value = "ruanganId") Integer ruanganId) {
		Map<String, Object> data = psrsPermintaanPerbaikanService.getAsetByProdukAndRuangan(produkId,ruanganId);
		return data;
	}
	
	
	@RequestMapping(value = "/save-perbaikan/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<Map<String, Object>> savePerbaikan(@Valid @RequestBody PerbaikanVO vo,HttpServletRequest request,HttpServletResponse response) {
		
		try {
			Map<String, Object> result = psrsPermintaanPerbaikanService.savePerbaikan(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 save Permintaan Perbaikan", 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 save Permintaan Perbaikan", jse.getMessage());
			addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
			return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
		}

	}
	
	@RequestMapping(value = "/save-pemeliharaan/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<Map<String, Object>> savePemeliharaan(@Valid @RequestBody PemeliharaanVO vo,HttpServletRequest request,HttpServletResponse response) {
		
		try {
			Map<String, Object> result = psrsPermintaanPerbaikanService.savePemeliharaan(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 save Permintaan Perbaikan", 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 save Permintaan Perbaikan", jse.getMessage());
			addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
			return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
		}

	}
	
	@RequestMapping(value = "/save-suku-cadang-luar/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<Map<String, Object>> saveSukuCadangLuar(@Valid @RequestBody List<SukuCadangLuarVO> vo,HttpServletRequest request,HttpServletResponse response) {
		
		try {
			Map<String, Object> result = psrsPermintaanPerbaikanService.saveSukuCadangLuar(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 save Permintaan Perbaikan", 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 save Permintaan Perbaikan", jse.getMessage());
			addHeaderMessage(Constants.MessageInfo.ERROR_MESSAGE, jse.getMessage());
			return RestUtil.getJsonHttptatus(HttpStatus.CONFLICT, mapHeaderMessage);
		}

	}
	
	@RequestMapping(value = "/get-stok-ruangan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public Map<String,Object>  getStokRuangan() {

		Map<String, Object> resultPageMap = stokProdukGlobalService.getStokRuangan();
		
		return resultPageMap;
	}
	
	@RequestMapping(value = "/verifikasi-ruangan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public Map<String,Object>  verifikasiRuangan(
				
			@RequestParam(value = "noRecKirimProduk", required = false) String noRec) {

		Map<String, Object> resultPageMap = strukOrderService.verifikasiRuangan(noRec);
		
		return resultPageMap;
	}
	
	@RequestMapping(value = "/monitoring", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public Map<String,Object>  monitoring(
				
			@RequestParam(value = "page", required = false, defaultValue = "0") Integer page,
			@RequestParam(value = "take", required = false, defaultValue = "10000") Integer limit,
			@RequestParam(value = "sort", required = false) String sort,
			@RequestParam(value = "dir", required = false, defaultValue = "asc") String dir,
			@RequestParam(value = "dateStart", required = false) String dateStart,
			@RequestParam(value = "dateEnd", required = false) String dateEnd,
			@RequestParam(value = "ruanganId", required = false) Integer ruanganId,
			@RequestParam(value = "noAset", required = false) String noAset,
			@RequestParam(value = "produkId", required = false) Integer produkId) {
		Map<String, Object> resultPageMap = strukOrderService.monitoringPerbaikan(page, limit, sort, dir, dateStart,dateEnd,ruanganId,noAset,produkId);
		
		return resultPageMap;
	}

	
	@RequestMapping(value = "/detail-monitoring", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public Map<String,Object>  detailMonitoring(
			@RequestParam(value = "strukOrderId", required = false) String strukOrderId,
			@RequestParam(value = "noRegistrasiAset", required = false) String noRegistrasiAset) {

		Map<String, Object> resultPageMap = strukOrderService.detailMonitoring(strukOrderId,noRegistrasiAset);
		
		return resultPageMap;
	}
	
	//add by iwankasan
	//12.12.2017
	@RequestMapping(value = "/get-lap-permintaan-perbaikan", 
			method = RequestMethod.GET, 
			produces = MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> getLapPermintaanPerbaikan(
			) {
		Map<String, Object> data = psrsPermintaanPerbaikanService.getLapPermintaanPerbaikan();
		return data;
	}
	
	@RequestMapping(value = "/get-lap-permintaan-perbaikan-by-date", 
			method = RequestMethod.GET, 
			produces = MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> getLapPermintaanPerbaikanByDate(
			@RequestParam(value = "startDate", required = false) String startDate,
			@RequestParam(value = "endDate", required = false) String endDate
			) {
		Map<String, Object> data = psrsPermintaanPerbaikanService.getLapPermintaanPerbaikanByDate(startDate, endDate);
		return data;
	}
	
	@RequestMapping(value = "/get-lap-permintaan-perbaikan-by-noorder", 
			method = RequestMethod.GET, 
			produces = MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> getLapPermintaanPerbaikanByNoTrans(
			@RequestParam(value = "noOrder", required = false) String noOrder
			) {
		Map<String, Object> data = psrsPermintaanPerbaikanService.getLapPermintaanPerbaikanByNoOrder(noOrder);
		return data;
	}
	
	@RequestMapping(value = "/get-lap-permintaan-perbaikan-by-jenis-order", 
			method = RequestMethod.GET, 
			produces = MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> getLapPermintaanPerbaikanByJenisOrder(
			@RequestParam(value = "startDate", required = false) String startDate,
			@RequestParam(value = "endDate", required = false) String endDate,
			@RequestParam(value = "jenisOrder", required = false) String jenisOrder
			) {
		Map<String, Object> data = psrsPermintaanPerbaikanService.getLapPermintaanPerbaikanByJenisOrder(jenisOrder, startDate, endDate);
		return data;
	}
	
	@RequestMapping(value = "/get-suku-cadang-by-strukorder", 
			method = RequestMethod.GET, 
			produces = MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> getOrderSukuCadangbyStrukOrder(String strukOrder) {
		Map<String, Object> data = this.psrsPermintaanPerbaikanService.getOrderSukuCadangbyStrukOrder(strukOrder);
		return data;
	}
	
	@RequestMapping(value = "/get-monitoring-perbaikan", 
			method = RequestMethod.GET, 
			produces = MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> getMonitoringPerbaikan(
			@RequestParam(value = "startDate", required = false) String startDate,
			@RequestParam(value = "endDate", required = false) String endDate
			) {
		Map<String, Object> data = this.psrsPermintaanPerbaikanService.getMonitoringPerbaikanByDate(startDate, endDate);
		return data;
	}
	
	@RequestMapping(value = "/get-asset-gedung-by-jenis-asset", 
			method = RequestMethod.GET, 
			produces = MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> getAssetGedungByJenisAsset(Integer idJenis) {
		Map<String, Object> data = this.psrsPermintaanPerbaikanService.getAssetGedungByJenisAsset(idJenis);
		return data;
	}
	
	@RequestMapping(value = "/get-asset-non-gedung-by-jenis-asset", 
			method = RequestMethod.GET, 
			produces = MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> getAssetNonGedungByJenisAsset(
			@RequestParam(value = "id", required = true) Integer id, 
			@RequestParam(value="idJenis", required=true) Integer idJenis, HttpServletRequest request) {
		Map<String, Object> data = this.psrsPermintaanPerbaikanService.getAssetNonGedungByJenisAsset(id, idJenis);
		return data;
	}
	
	@RequestMapping(value = "/get-asset-gedung-by-order-pelayanan", 
			method = RequestMethod.GET, 
			produces = MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> getAssetGedungByOrderPelayanan(
			@RequestParam(value = "noOrderPelayanan", required = false) String noOrderPelayanan, HttpServletRequest request) {
		Map<String, Object> data = this.psrsPermintaanPerbaikanService.getAssetGedungByOrderPelayanan(noOrderPelayanan);
		return data;
	}
	
	@RequestMapping(value = "/get-asset-non-gedung-by-order-pelayanan", 
			method = RequestMethod.GET, 
			produces = MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> getAssetNonGedungByOrderPelayanan(
			@RequestParam(value = "noOrderPelayanan", required = false) String noOrderPelayanan, HttpServletRequest request) {
		Map<String, Object> data = this.psrsPermintaanPerbaikanService.getAssetNonGedungByOrderPelayanan(noOrderPelayanan);
		return data;
	}
	
	@RequestMapping(value = "/get-asset-by-jenis-produk", 
			method = RequestMethod.GET, 
			produces = MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> getAssetByJenisProduk(@RequestParam(value="noRec")String noRec, HttpServletRequest request) {
		Map<String, Object> data = this.psrsPermintaanPerbaikanService.getRegistrasiAssetByJenisProduk(noRec);
		return data;
	}
	
}
