package com.jasamedika.medifirst2000.controller;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.query.Param;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
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.MessageResource;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.core.web.WebConstants;
import com.jasamedika.medifirst2000.dto.PelipatanDto;
import com.jasamedika.medifirst2000.dto.PenerimaanLinenDto;
import com.jasamedika.medifirst2000.dto.PenerimaanLinenExternalDto;
import com.jasamedika.medifirst2000.dto.PengeringanDto;
import com.jasamedika.medifirst2000.dto.ProsesCuciLinenDto;
import com.jasamedika.medifirst2000.dto.ProsesReturDto;
import com.jasamedika.medifirst2000.service.LaundryService;
import com.jasamedika.medifirst2000.service.StrukturNoCMService;
import com.jasamedika.medifirst2000.util.DateUtil;
import com.jasamedika.medifirst2000.util.rest.RestUtil;
import com.jasamedika.medifirst2000.vo.KirimProdukVO;

@RestController
@RequestMapping("/laundry")
public class LaundryController extends LocaleController<KirimProdukVO>{
	
	@Autowired
	private LaundryService laundryService;
	
	@Autowired
	private StrukturNoCMService strukturNoCMService;
	
	@RequestMapping(value="/get-all-penerimaan-linen", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<List<Map<String, Object>>> getAllPenerimaanLinen(
			@RequestParam(value="startPeriode",required=false) String startPeriode,
			@RequestParam(value="endPeriode",required=false) String endPeriode,
			HttpServletRequest request) {
		List<Map<String, Object>> result = laundryService.getAllPenerimaanLinen(DateUtil.toDate(startPeriode),
				DateUtil.toDate(endPeriode));
		
		if (result!=null) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}
	//savePermintaanLaundryInternal
	@RequestMapping(value="/save-penerimaan-linen", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<List<Map<String, Object>>> savePenerimaanLinen(
			@RequestBody List<PenerimaanLinenDto> dtos,
			HttpServletRequest request) {
		List<Map<String, Object>> result = laundryService.savePenerimaanLinen(dtos);
		if (!result.isEmpty()) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}
	
	@RequestMapping(value="/generate-no-struk", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<Map<String, Object>> getNoStruk(HttpServletRequest request) {
		Map<String, Object> result = laundryService.getGenerateNoStruk();
		
		if (!result.isEmpty()) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}

	@RequestMapping(value="/get-all-ruangan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<List<Map<String, Object>>> getAllRuangan(HttpServletRequest request) {
		List<Map<String, Object>> result = laundryService.getAllRuangan();
		
		if (!result.isEmpty()) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}

	@RequestMapping(value="/get-all-satuan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<List<Map<String, Object>>> getAllSatuan(HttpServletRequest request) {
		List<Map<String, Object>> result = laundryService.getAllSatuan();
		
		if (!result.isEmpty()) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}
	
	@RequestMapping(value="/get-all-penerimaan-linen-filter", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<List<Map<String, Object>>> getAllPenerimaanLinenFilter(
			@RequestParam(value="startPeriode",required=false) String startPeriode,
			@RequestParam(value="endPeriode",required=false) String endPeriode,
			HttpServletRequest request) {
		String newEndPeriode=changeTimeEndPeriode(endPeriode);
		List<Map<String, Object>> result = laundryService.getAllPenerimaanLinen(DateUtil.toDate(startPeriode),
				DateUtil.toDate(newEndPeriode));
		
		if (result!=null) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}

	private String changeTimeEndPeriode(String endPeriode) {
		Date newDate=new Date();
		String newEndPeriode;
		if(endPeriode != null){
			String tgl=endPeriode.split(" ")[0];
			String time=endPeriode.split(" ")[1];
			String timeStamp = new SimpleDateFormat("HH:mm:ss").format(newDate);
			newEndPeriode=tgl+" "+timeStamp;
		}else{
			newEndPeriode=endPeriode;
		}
		System.out.println("TIME END PERIODE : "+newEndPeriode);
		return newEndPeriode;
	}
	
	@RequestMapping(value="/send-penerimaan-to-pencucian", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<Map<String, Object>> sendPenerimaanToPencucian(
			@RequestBody List<PenerimaanLinenDto> dtos,
			HttpServletRequest request) {
		Map<String, Object> result = laundryService.sendPenerimaanToPencucian(dtos);
		if (!result.isEmpty()) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}

	@RequestMapping(value="/get-kapasitas-bahan-mesin", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<List<Map<String, Object>>> getKapasitasBahanMesin(
			@RequestParam(value="mesinId",required=true) Integer mesinId,
			HttpServletRequest request) {
		List<Map<String, Object>> result = laundryService.getKapasitasMesin(mesinId);
		
		if (!result.isEmpty()) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}

	@RequestMapping(value="/get-bahan-from-mesin-proses", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<List<Map<String, Object>>> getBahanMesinProses(
			@RequestParam(value="mesinId",required=true) Integer mesinId,
			@RequestParam(value="prosesCuciId",required=true) Integer prosesCuciId,
			HttpServletRequest request) {
		List<Map<String, Object>> result = laundryService.getAllBahanFromMesinAndProses(mesinId, prosesCuciId);
		
		if (result!=null) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}
	
	@RequestMapping(value="/save-proses-cuci", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<List<Map<String, Object>>> saveProsesCuci(
			@RequestBody ProsesCuciLinenDto dtos,
			HttpServletRequest request) {
		List<Map<String, Object>> result = laundryService.prosesCuci2(dtos);
		if (!result.isEmpty()) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}

	@RequestMapping(value="/get-all-pencucian", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<List<ProsesCuciLinenDto>> getAllPencucianFilter(
			@RequestParam(value="startPeriode",required=false) String startPeriode,
			@RequestParam(value="endPeriode",required=false) String endPeriode,
			HttpServletRequest request) {
		String newEndPeriode=changeTimeEndPeriode(endPeriode);
		List<ProsesCuciLinenDto> result = laundryService.getAllPencucianLinen(DateUtil.toDate(startPeriode),
				DateUtil.toDate(newEndPeriode));
		
		if (result!=null) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}

	@RequestMapping(value="/send-cuci-bilas", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<Map<String, Object>> sendPencucianToPembilasan(
			@RequestBody ProsesCuciLinenDto dtos,
			HttpServletRequest request) {
		Map<String, Object> result = laundryService.sendPencucianToPembilasan(dtos);
		if (!result.isEmpty()) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}

	@RequestMapping(value="/get-proses-bilas", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<List<Map<String, Object>>> getProsesBilas(
			@RequestParam(value="prosesCuci",required=true) String prosesCuci,
			HttpServletRequest request) {
		List<Map<String, Object>> result = laundryService.getProsesBilas(prosesCuci);
		
		if (result!=null) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}

	@RequestMapping(value="/save-pembilasan", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<List<Map<String, Object>>> savePembilasan(
			@RequestBody ProsesCuciLinenDto dtos,
			HttpServletRequest request) {
		List<Map<String, Object>> result = laundryService.prosesBilas(dtos);
		if (!result.isEmpty()) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}

	@RequestMapping(value="/get-all-pembilasan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<List<ProsesCuciLinenDto>> getAllPembilasanFilter(
			@RequestParam(value="startPeriode",required=false) String startPeriode,
			@RequestParam(value="endPeriode",required=false) String endPeriode,
			HttpServletRequest request) {
		
		String newEndPeriode=changeTimeEndPeriode(endPeriode);
		//exsisting error
		//List<ProsesCuciLinenDto> result = laundryService.getAllPembilasan2(DateUtil.toDate(startPeriode),
		//		DateUtil.toDate(newEndPeriode));
		
		List<ProsesCuciLinenDto> result = laundryService.getAllPembilasan(DateUtil.toDate(startPeriode),
				DateUtil.toDate(newEndPeriode));
		
		if (result!=null) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}

	@RequestMapping(value="/save-pengeringan", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<List<Map<String, Object>>> savePengeringan(
			@RequestBody PengeringanDto dtos,
			HttpServletRequest request) {
		List<Map<String, Object>> result = laundryService.prosesPengeringan(dtos);
		if (!result.isEmpty()) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}

	@RequestMapping(value="/get-all-pengeringan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<List<PengeringanDto>> getAllPengeringanFilter(
			@RequestParam(value="startPeriode",required=false) String startPeriode,
			@RequestParam(value="endPeriode",required=false) String endPeriode,
			HttpServletRequest request) {

		String newEndPeriode=changeTimeEndPeriode(endPeriode);
		List<PengeringanDto> result = laundryService.getAllPengeringan(DateUtil.toDate(startPeriode),
				DateUtil.toDate(newEndPeriode));
		
		if (result!=null) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}

	@RequestMapping(value="/get-produk-pelipatan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<List<Map<String,Object>>> getProdukPelipatanFilter(
			HttpServletRequest request) {
		List<Map<String,Object>> result = laundryService.getProdukPelipatan();
		
		if (result!=null) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}

	@RequestMapping(value="/save-pelipatan", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<List<Map<String, Object>>> savePelipatan(
			@RequestBody PelipatanDto dtos,
			HttpServletRequest request) {
		List<Map<String, Object>> result = laundryService.prosesPelipatan2(dtos);
		if (!result.isEmpty()) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}

	@RequestMapping(value="/get-all-pelipatan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<List<PengeringanDto>> getAllPelipatanFilter(
			@RequestParam(value="startPeriode",required=false) String startPeriode,
			@RequestParam(value="endPeriode",required=false) String endPeriode,
			HttpServletRequest request) {
		String newEndPeriode=changeTimeEndPeriode(endPeriode);

		List<PengeringanDto> result = laundryService.getAllPelipatan(DateUtil.toDate(startPeriode),
				DateUtil.toDate(newEndPeriode));
		
		if (result!=null) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}

	@RequestMapping(value="/cek-stok-ruangan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<List<Map<String, Object>>> cekStokRuangan(
			@RequestBody ProsesCuciLinenDto dtos,
			HttpServletRequest request) {
		List<Map<String, Object>> result = laundryService.cekStokRuangan(dtos);
		if (result!=null) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}

	@RequestMapping(value="/cek-produk-pelipatan", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<Map<String, Object>> cekProdukPelipatan(
			@RequestBody PelipatanDto dto,
			HttpServletRequest request) {
		Map<String, Object> result = laundryService.cekProdukLipat2(dto);
		if (result!=null) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}

	@RequestMapping(value="/get-produk-penerimaan-linen-external", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<List<Map<String,Object>>> getProdukPenerimaanLinenExternal(
			HttpServletRequest request) {
		List<Map<String,Object>> result = laundryService.getProdukPenerimaanLinenExternal();
		
		if (result!=null) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}

	@RequestMapping(value="/get-detail-penerimaan-linen-external", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<List<Map<String,Object>>> getDetailPenerimaanLinenExternal(
			@RequestParam(value="noRecStrukPelayanan",required=true) String noRecStrukPelayanan,
			HttpServletRequest request) {
		List<Map<String,Object>> result = laundryService.getDetailPenerimaanLinenExternal(noRecStrukPelayanan);
		
		if (result!=null) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}

	@RequestMapping(value="/save-penerimaan-linen-external", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<List<Map<String, Object>>> savePenerimaanLinenEkternal(
			@RequestBody PenerimaanLinenExternalDto dto,
			HttpServletRequest request) {
		List<Map<String, Object>> result = laundryService.savePenerimaanLinenExternal(dto);
		if (!result.isEmpty()) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}

	@RequestMapping(value="/send-pengeringan-to-pelipatan-external", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<Map<String, Object>> sendPengeringanToPelipatanExternal(
			@RequestBody List<PenerimaanLinenDto> dtos,
			HttpServletRequest request) {
		Map<String, Object> result = laundryService.sendPenerimaanToPencucian(dtos);
		if (!result.isEmpty()) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}

	@RequestMapping(value="/get-satuan-potong", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<List<Map<String, Object>>> getAllSatuanPotong(HttpServletRequest request) {
		List<Map<String, Object>> result = laundryService.getAllSatuanPotong();
		
		if (!result.isEmpty()) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}

	@RequestMapping(value="/get-pembilasan-to-pengeringan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<ProsesCuciLinenDto> getPembilasanToPengeringan(
			@RequestParam(value="noRecStrukPelayanan",required=true) String noRecStrukPelayanan,
			HttpServletRequest request) {
		ProsesCuciLinenDto dto=new ProsesCuciLinenDto();
		dto.setNoRecStrukPelayanan(noRecStrukPelayanan);
		ProsesCuciLinenDto result = laundryService.sendPembilasanToPengeringan(dto);
		if (result!=null) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}

	@RequestMapping(value="/get-pengeringan-to-pelipatan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<ProsesCuciLinenDto> getPengeringanToPelipatan(
			@RequestParam(value="noRecStrukPelayanan",required=true) String noRecStrukPelayanan,
			HttpServletRequest request) {
		ProsesCuciLinenDto dto=new ProsesCuciLinenDto();
		dto.setNoRecStrukPelayanan(noRecStrukPelayanan);
		ProsesCuciLinenDto result = laundryService.sendPengeringanToPelipatan(dto);
		if (result!=null) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}

	@RequestMapping(value="/get-struk-order-laundry-eksternal", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<Map<String, Object>> getStrukOrderExternal(
			@RequestParam(value="noRecStrukPelayanan",required=true) String noRecStrukPelayanan,
			HttpServletRequest request) {
		Map<String, Object> result = laundryService.getStrukOrderExternal(noRecStrukPelayanan);
		
		if (!result.isEmpty()) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}
	
	@RequestMapping(value="/get-all-pengambilan-eksternal", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<List<PengeringanDto>> getAllPengambilanLinenEksternal(
			@RequestParam(value="namaPelanggan",required=false) String namaPelanggan,
			@RequestParam(value="startPeriode",required=false) String startPeriode,
			@RequestParam(value="endPeriode",required=false) String endPeriode,
			HttpServletRequest request) {
		String newEndPeriode=changeTimeEndPeriode(endPeriode);

		List<PengeringanDto> result = laundryService.getAllPengambilanLinenEksternal(namaPelanggan,
				DateUtil.toDate(startPeriode),DateUtil.toDate(newEndPeriode));
		
		if (result!=null) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}

	@RequestMapping(value="/save-pengambilan", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<Map<String, Object>> savePengambilan(
			@RequestBody ProsesCuciLinenDto dto,
			HttpServletRequest request) {
		Map<String, Object> result = laundryService.prosesPengambilan(dto);
		if (!result.isEmpty()) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}

	@RequestMapping(value="/retur-laundry", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<Map<String, Object>> saveReturLaundry(
			@RequestBody ProsesReturDto dto,
			HttpServletRequest request) {
		Map<String, Object> result = laundryService.prosesReturLaundry(dto);
		if (!result.isEmpty()) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}

	@RequestMapping(value="/get-retur-linen", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<PengeringanDto> getAllReturLinen(
			@RequestParam(value="noRecStrukPelayanan",required=true) String noRecStrukPelayanan,
			HttpServletRequest request) {
		PengeringanDto dto=new PengeringanDto();
		dto.setNoRecStrukPelayanan(noRecStrukPelayanan);
		PengeringanDto result = laundryService.sendPengambilanLinenToReturLinen(dto);
		if (result!=null) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}

	@RequestMapping(value="/get-all-retur-linen", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<List<ProsesReturDto>> getAllReturLinen(
			@RequestParam(value="startPeriode",required=false) String startPeriode,
			@RequestParam(value="endPeriode",required=false) String endPeriode,
			HttpServletRequest request) {
		String newEndPeriode=changeTimeEndPeriode(endPeriode);
		List<ProsesReturDto> result = laundryService.getAllRetur(DateUtil.toDate(startPeriode),
				DateUtil.toDate(newEndPeriode));
		if (result!=null) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}

	@RequestMapping(value="/get-no-cm-laundry", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<String> getNoCmLaundry(
			HttpServletRequest request) {
		String result = strukturNoCMService.getStrukturNoCm("NoCmLaundry", 15, 1);
		
		if (result!=null) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}
	
	
	@RequestMapping(value="/save-order-linen-external", 
			method = RequestMethod.POST, 
			produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<Map<String, Object>> saveOrderLinenInternal(
			@RequestBody PenerimaanLinenExternalDto dto,
			HttpServletRequest request) {
		Map<String, Object> result = this.laundryService.savePermintaanLaundryExternal(dto);
		if (!result.isEmpty()) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}
	
	//sesuai dengan meeting tgl.11.07.2018
	//dibuatkan form untuk pengambilan linen kotor
	@RequestMapping(value="/save-pengambilan-linen-internal",
			method = RequestMethod.POST, 
			produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<Map<String, Object>> savePengambilanLinenInternal(
			@RequestBody PenerimaanLinenExternalDto dto,
			HttpServletRequest request) {
		Map<String, Object> result = this.laundryService.savePengambilanLaundryInternal(dto);
		if (!result.isEmpty()) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}
	
	
	//diaktifkan lagi sesuai dengan permintaan 
	//hasil meeting dengan team laundry (ibu merlin,dkk)
	//tgl.18.05.2018
	@RequestMapping(value="/save-penerimaan-linen-internal",
			method = RequestMethod.POST, 
			produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<Map<String, Object>> savePenerimaanLinenInternal(
			@RequestBody PenerimaanLinenExternalDto dto,
			HttpServletRequest request) {
		Map<String, Object> result = this.laundryService.savePenerimaanLaundryInternal(dto);
		if (!result.isEmpty()) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}
	
	//digunakan untuk getData Pengambilan linen Kotor dari Ruangan
	//sesuai degan review oleh team laundry
	//date : 11.05.2018
	//tgl.17.05.2018
	//diubah lagi dari pengambilan linen kotor menjadi permintaan linen bersih dari ruangan
	@RequestMapping(value="/get-permintaan-linen-bersih-dari-ruangan", 
			method=RequestMethod.GET, 
			produces=MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> getOrderLaundrySebelumDiterima(
			@RequestParam(value="startDate",required=false) String startDate,
			@RequestParam(value="endDate",required=false) String endDate,
			HttpServletRequest request){
		Map<String, Object> result = this.laundryService.getOrderLaundrySebelumDiTerima(startDate, endDate);
		return result;
	}
	
	//tgl.17.05.2018
	//pengambilan linen kotor
	@RequestMapping(value="/get-pengambilan-linen-kotor", 
			method=RequestMethod.GET, 
			produces=MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> getPengambilanLinenKotor(
			@RequestParam(value="startDate",required=false) String startDate,
			@RequestParam(value="endDate",required=false) String endDate,
			HttpServletRequest request){
		Map<String, Object> result = this.laundryService.getPengambilanLinenKotor(startDate, endDate);
		return result;
	}

	//tgl.17.05.2018
	//pengambilan linen kotor
	@RequestMapping(value="/get-pengambilan-linen-kotor-by-norec", 
			method=RequestMethod.GET, 
			produces=MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> getPengambilanLinenKotorByNoRec(
			@RequestParam(value="noRec",required=false) String noRec, HttpServletRequest request){
		Map<String, Object> result = this.laundryService.getPengambilanLinenKotorByNoRec(noRec);
		return result;
	}
	
	
	//digunakan untuk getData Pengambilan linen Kotor dari Ruangan
	//sesuai degan review oleh team laundry,
	//sesuai dengan hasil meeting
	//tgl : 11.05.2018
	//diubah lagi dari pengambilan linen kotor menjadi permintaan linen bersih dari ruangan,
	//berdasarkan hasil meeting 
	//tgl.17.05.2018
	@RequestMapping(value="/get-permintaan-linen-bersih-detail",
			method=RequestMethod.GET, 
			produces=MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> getPengambilanLinenKotorDetail(
			@RequestParam("noRec")String noRec, HttpServletRequest request){
		Map<String, Object> result = this.laundryService.getOrderLaundrySebelumDiTerimaDetail(noRec);
		return result;
	}
	
	@RequestMapping(value="/get-order-laundry-diterima", 
			method=RequestMethod.GET, 
			produces=MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> getOrderLaundryDiterima(){
		Map<String, Object> result = this.laundryService.getOrderLaundryDiterima();
		return result;
	}
	
	@RequestMapping(value="/get-order-laundry-diterima-detail",
			method=RequestMethod.GET, 
			produces=MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> gerOrderLaundrySebelumDeterimaDetail(
			@RequestParam("noRec")String noRec, HttpServletRequest request){
		Map<String, Object> result = this.laundryService.getOrderLaundryDiterimaDetail(noRec);
		return result;
	}
	
	//by iwankasan
	//ditest : 05.02.2018
	//proses-cuci-internal
	@RequestMapping(value="/save-proses-cuci-internal-1", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<List<Map<String, Object>>> saveProsesCuciInternal1(
			@RequestBody ProsesCuciLinenDto dtos,
			HttpServletRequest request) {
		List<Map<String, Object>> result = laundryService.prosesCuci(dtos);
		if (!result.isEmpty()) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}
	
	@RequestMapping(value="/save-proses-cuci-internal", 
			method = RequestMethod.POST, 
			produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<Map<String, Object>> saveProsesCuciInternal(
			@RequestBody ProsesCuciLinenDto dtos,
			HttpServletRequest request) {
		Map<String, Object> result = this.laundryService.saveProsesPencucianInternal(dtos);
		if (!result.isEmpty()) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}
	
	@RequestMapping(value="/save-proses-cuci-external", 
			method = RequestMethod.POST, 
			produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<Map<String, Object>> saveProsesCuciExternal(
			@RequestBody ProsesCuciLinenDto dtos,
			HttpServletRequest request) {
		Map<String, Object> result = this.laundryService.saveProsesPencucianExternal(dtos);
		if (!result.isEmpty()) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}
	
	@RequestMapping(value="/get-proses-cuci",
			method=RequestMethod.GET, 
			produces=MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> gerProsesCuci(
			@RequestParam("startDate")String startDate, 
			@RequestParam("endDate")String endDate,
			HttpServletRequest request){
		Map<String, Object> result = this.laundryService.getProsesCucianInternal(startDate, endDate);
		return result;
	}
	
	@RequestMapping(value="/get-proses-cuci-external",
			method=RequestMethod.GET, 
			produces=MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> gerProsesCuciExternal(
			@RequestParam("startDate")String startDate, @RequestParam("endDate")String endDate, HttpServletRequest request){
		Map<String, Object> result = this.laundryService.getProsesCucianExternal(startDate, endDate);
		return result;
	}
	
	@RequestMapping(value="/get-proses-cuci-by-norec",
			method=RequestMethod.GET, 
			produces=MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> gerProsesCuciByNoRec(@RequestParam("noRec")String noRec, HttpServletRequest request){
		Map<String, Object> result = this.laundryService.getProsesCuciianInternalByNoRec(noRec);
		return result;
	}
	
	@RequestMapping(value="/get-proses-cuci-external-by-norec",
			method=RequestMethod.GET, 
			produces=MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> gerProsesCuciExternalByNoRec(@RequestParam("noRec")String noRec, HttpServletRequest request){
		Map<String, Object> result = this.laundryService.getProsesCucianExternalByNoRec(noRec);
		return result;
	}
	
	@RequestMapping(value="/save-proses-pengeringan-internal", 
			method = RequestMethod.POST, 
			produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<Map<String, Object>> saveProsesPengeringan(
			@RequestBody PengeringanDto dto, HttpServletRequest request){
		Map<String, Object> result = this.laundryService.savePengeringanInternal(dto);
		if (!result.isEmpty()) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}
	
	@RequestMapping(value="/save-proses-pengeringan-external", 
			method = RequestMethod.POST, 
			produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<Map<String, Object>> saveProsesPengeringanExternal(
			@RequestBody PengeringanDto dto, HttpServletRequest request){
		Map<String, Object> result = this.laundryService.savePengeringanExternal(dto);
		if (!result.isEmpty()) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}
	
	@RequestMapping(value="/get-proses-pengeringan",
			method=RequestMethod.GET, 
			produces=MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> getProsesPengeringan(
			@RequestParam("startDate")String startDate, 
			@RequestParam("endDate")String endDate, HttpServletRequest request){
		Map<String, Object> result = this.laundryService.getProsesPengeringanInternal(startDate, endDate);
		return result;
	}
	
	@RequestMapping(value="/get-proses-pengeringan-external",
			method=RequestMethod.GET, 
			produces=MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> getProsesPengeringanExternal(
			@RequestParam("startDate")String startDate, 
			@RequestParam("endDate")String endDate, HttpServletRequest request){
		Map<String, Object> result = this.laundryService.getProsesPengeringanExternal(startDate, endDate);
		return result;
	}
	
	@RequestMapping(value="/get-proses-pengeringan-by-norec",
			method=RequestMethod.GET, 
			produces=MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> gerProsesPengeringanByNoRec(@RequestParam("noRec")String noRec, HttpServletRequest request){
		Map<String, Object> result = this.laundryService.getProsesPengeringanInternalByNoRec(noRec);
		return result;
	}
	
	@RequestMapping(value="/get-proses-pengeringan-external-by-norec",
			method=RequestMethod.GET, 
			produces=MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> gerProsesPengeringanExternalByNoRec(@RequestParam("noRec")String noRec, HttpServletRequest request){
		Map<String, Object> result = this.laundryService.getProsesPengeringanExternalByNoRec(noRec);
		return result;
	}
	
	@RequestMapping(value="/save-proses-pelipatan", 
			method = RequestMethod.POST, 
			produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<Map<String, Object>> saveProsesPelipatan(
			@RequestBody PelipatanDto dto, HttpServletRequest request){
		Map<String, Object> result = this.laundryService.savePelipatanInternal(dto);
		if (!result.isEmpty()) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}
	
	@RequestMapping(value="/save-proses-pelipatan-external", 
			method = RequestMethod.POST, 
			produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<Map<String, Object>> saveProsesPelipatanExternal(
			@RequestBody PelipatanDto dto, HttpServletRequest request){
		Map<String, Object> result = this.laundryService.savePelipatanExternal(dto);
		if (!result.isEmpty()) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}
	
	@RequestMapping(value="/get-proses-pelipatan",
			method=RequestMethod.GET, 
			produces=MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> getProsesPelipatan(
			@RequestParam("startDate")String startDate, 
			@RequestParam("endDate")String endDate, HttpServletRequest request){
		Map<String, Object> result = this.laundryService.getProsesPelipatan(startDate, endDate);
		return result;
	}
	
	@RequestMapping(value="/get-proses-pelipatan-external",
			method=RequestMethod.GET, 
			produces=MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> getProsesPelipatanExternal(
			@RequestParam("startDate")String startDate, 
			@RequestParam("endDate")String endDate, HttpServletRequest request){
		Map<String, Object> result = this.laundryService.getProsesPelipatanExternal(startDate, endDate);
		return result;
	}
	
	@RequestMapping(value="/get-proses-pelipatan-by-norec",
			method=RequestMethod.GET, 
			produces=MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> gerProsesPelipatanByNoRec(
			@RequestParam("noRec")String noRec, 
			HttpServletRequest request){
		Map<String, Object> result = this.laundryService.getProsesPelipatanByNoRec(noRec);
		return result;
	}
	
	@RequestMapping(value="/get-proses-pelipatan-external-by-norec",
			method=RequestMethod.GET, 
			produces=MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> gerProsesPelipatanExternalByNoRec(
			@RequestParam("noRec")String noRec, 
			HttpServletRequest request){
		Map<String, Object> result = this.laundryService.getProsesPelipatanExternalByNoRec(noRec);
		return result;
	}
	
	@RequestMapping(value="/save-proses-rollpress", 
			method = RequestMethod.POST, 
			produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<Map<String, Object>> saveProsesRollPress(
			@RequestBody PelipatanDto dto, HttpServletRequest request){
		Map<String, Object> result = this.laundryService.saveRollPressInternal(dto);
		if (!result.isEmpty()) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}
	
	@RequestMapping(value="/save-proses-rollpress-external", 
			method = RequestMethod.POST, 
			produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<Map<String, Object>> saveProsesRollPressExternal(
			@RequestBody PelipatanDto dto, HttpServletRequest request){
		Map<String, Object> result = this.laundryService.saveRollPressExternal(dto);
		if (!result.isEmpty()) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}
	
	@RequestMapping(value="/get-proses-rollpress",
			method=RequestMethod.GET, 
			produces=MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> getProsesRollPress(
			@RequestParam("startDate")String startDate, 
			@RequestParam("endDate")String endDate, HttpServletRequest request){
		Map<String, Object> result = this.laundryService.getProsesRollPress(startDate, endDate);
		return result;
	}
	
	@RequestMapping(value="/get-proses-rollpress-external",
			method=RequestMethod.GET, 
			produces=MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> getProsesRollPressExternal(
			@RequestParam("startDate")String startDate, 
			@RequestParam("endDate")String endDate, HttpServletRequest request){
		Map<String, Object> result = this.laundryService.getProsesRollPressExternal(startDate, endDate);
		return result;
	}
	
	@RequestMapping(value="/get-proses-rollpress-by-norec",
			method=RequestMethod.GET, 
			produces=MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> getProsesRollPressByNoRec(
			@RequestParam("noRec")String noRec, 
			HttpServletRequest request){
		Map<String, Object> result = this.laundryService.getProsesRollPressByNoRec(noRec);
		return result;
	}
	
	@RequestMapping(value="/get-proses-rollpress-external-by-norec",
			method=RequestMethod.GET, 
			produces=MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> getProsesRollPressExternalByNoRec(
			@RequestParam("noRec")String noRec, 
			HttpServletRequest request){
		Map<String, Object> result = this.laundryService.getProsesRollPressExternalByNoRec(noRec);
		return result;
	}
	
	@RequestMapping(value="/get-bahan-laundry",
			method=RequestMethod.GET, 
			produces=MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> getBahanLaundry(HttpServletRequest request){
		Map<String, Object> result = this.laundryService.getBahanLaundry();
		return result;
	}
	
	@RequestMapping(value="/get-laundry-linen-bersih", 
			method=RequestMethod.GET, 
			produces=MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> getStockLaundryLinenBersih(HttpServletRequest request) {
		Map<String, Object> result = this.laundryService.getStockLaundryLinenBersih();
		return result;
	}
	
	@RequestMapping(value="/save-distribusi-linen", 
			method = RequestMethod.POST, 
			produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<Map<String, Object>> saveDistribusiLinen(
			@RequestBody PenerimaanLinenExternalDto dto, HttpServletRequest request){
		Map<String, Object> result = this.laundryService.savePenditribusianLinenInternal(dto);
		if (!result.isEmpty()) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}
	
	@RequestMapping(value="/get-distribusi-linen-bersih", 
			method=RequestMethod.GET, 
			produces=MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> getDistribusiLinenBersih(
			@RequestParam("startDate")String startDate, 
			@RequestParam("endDate")String endDate, HttpServletRequest request) {
		Map<String, Object> result = this.laundryService.getDistribusiLinen(startDate, endDate);
		return result;
	}
	
	@RequestMapping(value="/get-distribusi-linen-bersih-by-ruangan", 
			method=RequestMethod.GET, 
			produces=MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> getDistribusiLinenBersihByRuangan(
			@RequestParam("startDate")String startDate, 
			@RequestParam("endDate")String endDate, HttpServletRequest request) {
		Map<String, Object> result = this.laundryService.getDistribusiLinenByRuangan(startDate, endDate);
		return result;
	}
	
	@RequestMapping(value="/save-verifikasi-penerimaan-linenbersih", 
			method = RequestMethod.POST, 
			produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<Map<String, Object>> saveVerifikasiPenerimaanLinenBersih(
			@RequestBody PenerimaanLinenDto dto, HttpServletRequest request){
		Map<String, Object> result = this.laundryService.updateTanggalTerimaLinenBersihByRuangan(dto);
		if (!result.isEmpty()) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}
	
	
	@RequestMapping(value="/get-distribusi-linen-bersih-detail", 
			method=RequestMethod.GET, 
			produces=MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> getDistribusiLinenBersihDetailByRuangan(
			@RequestParam("noRec")String noRec, HttpServletRequest request) {
		Map<String, Object> result = this.laundryService.getDistribusiLinenBersihDetailByNoRec(noRec);
		return result;
	}
	
	
	@RequestMapping(value = "/get-penerimaan-linen-internal-by-periode", 
			method = RequestMethod.GET, 
			produces = MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> getPenerimaanLinenInternalByDate(
			@RequestParam(value = "startDate") String startDate,
			@RequestParam(value = "endDate") String endDate
			) {
		Map<String, Object> result = this.laundryService.getPenerimaanLinenInternal(startDate, endDate);
		return result;
	}
	
	@RequestMapping(value = "/get-penerimaan-linen-external-by-periode", 
			method = RequestMethod.GET, 
			produces = MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> getPenerimaanLinenExternalByDate(
			@RequestParam(value = "startDate") String startDate,
			@RequestParam(value = "endDate") String endDate
			) {
		Map<String, Object> result = this.laundryService.getPenerimaanLinenExternal(startDate, endDate);
		return result;
	}
	
	@RequestMapping(value = "/get-distribusi-linen-external", 
			method = RequestMethod.GET, 
			produces = MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> getDistribusiLinenExternal(
			@RequestParam(value = "startDate") String startDate,
			@RequestParam(value = "endDate") String endDate
			) {
		Map<String, Object> result = this.laundryService.getDistribusiLinenExternal(startDate, endDate);
		return result;
	}

	@RequestMapping(value="/get-distribusi-linen-external-by-norec", 
			method=RequestMethod.GET, 
			produces=MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> getDistribusiLinenBersihDetailByNoRec(
			@RequestParam("noRec")String noRec, HttpServletRequest request) {
		Map<String, Object> result = this.laundryService.getDistribusiLinenExternalByNoRec(noRec);
		return result;
	}
	
	@RequestMapping(value="/save-distribusi-linen-external", 
			method = RequestMethod.POST, 
			produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<Map<String, Object>> saveDistribusiLinenExternal(
			@RequestBody PenerimaanLinenExternalDto dto, HttpServletRequest request){
		Map<String, Object> result = this.laundryService.savePenditribusianLinenExternal(dto);
		if (!result.isEmpty()) {
			mapHeaderMessage.put(WebConstants.HttpHeaderInfo.LABEL_SUCCESS, getMessage(MessageResource.LABEL_SUCCESS, request));
			return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
		}
		return RestUtil.getJsonHttptatus(HttpStatus.INTERNAL_SERVER_ERROR, mapHeaderMessage);
	}
	
	@RequestMapping(value="/get-jenis-linen", 
			method=RequestMethod.GET, 
			produces=MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> getJenisLinen(HttpServletRequest request) {
		Map<String, Object> result = this.laundryService.getJenisLinen();
		return result;
	}
	
	@RequestMapping(value="/get-mesin-by-jenis-linen", 
			method=RequestMethod.GET, 
			produces=MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> getMesinByJenisLinen(
			@RequestParam("idJenis")Integer idJenis, HttpServletRequest request) {
		Map<String, Object> result = this.laundryService.getMesinByJenisLinen(idJenis);
		return result;
	}
	
	@RequestMapping(value="/get-produk-by-mesin-jenis-linen", 
			method=RequestMethod.GET, 
			produces=MediaType.APPLICATION_JSON_VALUE)
	public Map<String, Object> getProdukByMesinJenisLinen(
			@RequestParam("idJenis")Integer idJenis, @RequestParam("idMesin")Integer idMesin, HttpServletRequest request) {
		Map<String, Object> result = this.laundryService.getMappingProdukByJenisLinen(idJenis, idMesin);
		return result;
	}
	
		
}
