ENDRPrint_12CRelease/.svn/pristine/1e/1e7124af8667cf255666b8820c288f179ae494db.svn-base
2024-08-14 10:58:03 +07:00

86 lines
3.0 KiB
Plaintext
Raw Blame History

package th.co.muangthai.endrprint.controller;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import th.co.muangthai.endrprint.controller.service.ENDR200Service;
import th.co.muangthai.endrprint.model.bean.form.MsgErrorForm;
import th.co.muangthai.endrprint.model.bean.form.data.PrintingDataForm;
import th.co.muangthai.endrprint.model.bean.form.master.EndrUserLoginForm;
import th.co.muangthai.endrprint.util.SessionUtil;
import th.co.muangthai.endrprint.util.VSMUtil;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
/**
* ENDR Print management.
*/
@Controller
public class ENDR200Controller extends ENDR200Service {
static Logger log = Logger.getLogger(ENDR200Controller.class);
/**
* Load the information/data to start (Master ,ComboBox)
* @param request
* @return Object[] search results
*/
@RequestMapping(value = "/json/ENDR200LoadData", method = RequestMethod.POST)
public @ResponseBody
Object[] loadData(HttpServletRequest request) {
MsgErrorForm errorForm = new MsgErrorForm();
errorForm.setDataDefaultOk();
List<EndrUserLoginForm> lst = new ArrayList<EndrUserLoginForm>();
try {
String userId = SessionUtil.getUserLoginForm().getUserId();
if (VSMUtil.isNotEmpty(userId)){
lst = commonService.searchLstUserLoginBeanFormPkg(null, null, null, null);
} else {
errorForm.setErrorFlag(getBigDecimal("1"));
errorForm.setErrorDesc("out of session");
}
} catch (Exception ex) {
errorForm.setDataErrorException(ex);
log.error(ex.toString(), ex);
}
return new Object[]{errorForm,lst};
}
/**
* ENDR Print information searching regarding the condition
* @param request
* @return Object[] search results
*/
@RequestMapping(value = "/json/ENDR200SchData", method = RequestMethod.POST)
public @ResponseBody
Object[] schData(HttpServletRequest request) {
MsgErrorForm errorForm = new MsgErrorForm();
errorForm.setDataDefaultOk();
List<PrintingDataForm> lstPrintingData = new ArrayList<PrintingDataForm>();
try {
// <20>Ѻ Param <20>ҡ Pages
String schFormParam = request.getParameter("schFormParam");
PrintingDataForm schForm = gsonData.fromJson(schFormParam, PrintingDataForm.class);
if (VSMUtil.isEmpty(schForm.getTeam())){
schForm.setTeam(null);
}
schForm.setType("0"); //print
lstPrintingData = commonService.searchPrintingDataFormPkg(schForm);
} catch (Exception ex) {
errorForm.setDataErrorException(ex);
log.error(ex.toString(), ex);
}
return new Object[]{errorForm ,lstPrintingData};
}
}