160 lines
6.1 KiB
Plaintext
160 lines
6.1 KiB
Plaintext
package th.co.muangthai.endrprint.controller;
|
|
|
|
import org.apache.log4j.Logger;
|
|
import org.springframework.beans.BeanUtils;
|
|
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.ENDR400Service;
|
|
import th.co.muangthai.endrprint.model.bean.form.MsgErrorForm;
|
|
import th.co.muangthai.endrprint.model.bean.form.master.EndrPrintServerForm;
|
|
import th.co.muangthai.endrprint.model.bean.form.master.EndrProvincialForm;
|
|
import th.co.muangthai.endrprint.model.bean.form.master.EndrProvincialPrintForm;
|
|
import th.co.muangthai.endrprint.model.bean.form.master.EndrUserLoginForm;
|
|
import th.co.muangthai.endrprint.model.bean.master.EndrPrintServerBean;
|
|
import th.co.muangthai.endrprint.model.bean.master.EndrProvincialBean;
|
|
import th.co.muangthai.endrprint.model.bean.master.EndrProvincialPrintBean;
|
|
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 ENDR400Controller extends ENDR400Service {
|
|
static Logger log = Logger.getLogger(ENDR400Controller.class);
|
|
|
|
/**
|
|
* Load the information/data to start (Master ,ComboBox)
|
|
*
|
|
* @param request
|
|
* @return Object[] search results
|
|
*/
|
|
@RequestMapping(value = "/json/ENDR400LoadData", method = RequestMethod.POST)
|
|
public
|
|
@ResponseBody
|
|
Object[] loadData(HttpServletRequest request) {
|
|
Object[] obj = new Object[4];
|
|
MsgErrorForm errorForm = new MsgErrorForm();
|
|
errorForm.setDataDefaultOk();
|
|
List<EndrUserLoginForm> lst = new ArrayList<EndrUserLoginForm>();
|
|
|
|
//master
|
|
List<EndrProvincialBean> endrProvincialList = new ArrayList<EndrProvincialBean>();
|
|
List<EndrPrintServerBean> endrPrintServerList = new ArrayList<EndrPrintServerBean>();
|
|
|
|
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");
|
|
}
|
|
//load Master
|
|
// EndrPrintServerForm endrPrintServerForm = new EndrPrintServerForm();
|
|
// endrPrintServerForm.setStatusFlag(BigDecimal.ONE);
|
|
endrProvincialList = commonService.searchEndrProvincialByBean(new EndrProvincialForm());
|
|
endrPrintServerList = commonService.searchEndrPrintServerByBean(new EndrPrintServerForm());
|
|
|
|
|
|
obj[0] = errorForm;
|
|
obj[1] = lst;
|
|
obj[2] = endrProvincialList;
|
|
obj[3] = endrPrintServerList;
|
|
} catch (Exception ex) {
|
|
errorForm.setDataErrorException(ex);
|
|
log.error(ex.toString(), ex);
|
|
obj[0] = errorForm;
|
|
}
|
|
return obj;
|
|
}
|
|
|
|
/**
|
|
* ENDR Print information searching regarding the condition
|
|
*
|
|
* @param request
|
|
* @return Object[] search results
|
|
*/
|
|
@RequestMapping(value = "/json/ENDR400SchData", method = RequestMethod.POST)
|
|
public
|
|
@ResponseBody
|
|
Object[] schData(HttpServletRequest request) {
|
|
MsgErrorForm errorForm = new MsgErrorForm();
|
|
errorForm.setDataDefaultOk();
|
|
List<EndrProvincialPrintForm> endrProvincialPrintList = new ArrayList<EndrProvincialPrintForm>();
|
|
try {
|
|
String schFormParam = request.getParameter("schFormParam");
|
|
EndrProvincialPrintForm endrProvincialPrintForm = gsonData.fromJson(schFormParam, EndrProvincialPrintForm.class);
|
|
|
|
//Load Mapping Data By getProvincialId & getServerId & all StatusFlag
|
|
endrProvincialPrintList = commonService.searchEndrProvincialPrintByPkg(
|
|
endrProvincialPrintForm.getProvincialId(),
|
|
endrProvincialPrintForm.getServerId(),
|
|
null
|
|
);
|
|
|
|
|
|
} catch (Exception ex) {
|
|
errorForm.setDataErrorException(ex);
|
|
log.error(ex.toString(), ex);
|
|
}
|
|
return new Object[]{errorForm, endrProvincialPrintList};
|
|
}
|
|
|
|
/**
|
|
* ENDR400InsertData
|
|
*
|
|
* @param request
|
|
* @return Object[] search results
|
|
*/
|
|
@RequestMapping(value = "/json/ENDR400InsertData", method = RequestMethod.POST)
|
|
public
|
|
@ResponseBody
|
|
Object[] ENDR400InsertData(HttpServletRequest request) {
|
|
Object[] obj = new Object[4];
|
|
MsgErrorForm errorForm = new MsgErrorForm();
|
|
errorForm.setDataDefaultOk();
|
|
|
|
String insertFormParam = request.getParameter("insertFormParam");
|
|
EndrProvincialPrintForm insertForm = gsonData.fromJson(insertFormParam, EndrProvincialPrintForm.class);
|
|
try {
|
|
obj = insertEndrProvincialPrint(insertForm.getProvincialId(), insertForm.getServerId());
|
|
} catch (Exception ex) {
|
|
errorForm.setDataErrorException(ex);
|
|
log.error(ex.toString(), ex);
|
|
obj[0] = errorForm;
|
|
}
|
|
return obj;
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/json/ENDR400DeleteData", method = RequestMethod.POST)
|
|
public
|
|
@ResponseBody
|
|
Object[] ENDR400DeleteData(HttpServletRequest request) {
|
|
Object[] obj = new Object[2];
|
|
MsgErrorForm errorForm = new MsgErrorForm();
|
|
errorForm.setDataDefaultOk();
|
|
|
|
String deleteFormParam = request.getParameter("deleteFormParam");
|
|
EndrProvincialPrintForm deleteForm = gsonData.fromJson(deleteFormParam, EndrProvincialPrintForm.class);
|
|
EndrProvincialPrintBean bean = new EndrProvincialPrintBean();
|
|
BeanUtils.copyProperties(deleteForm, bean);
|
|
try {
|
|
obj = deleteEndrProvincialPrint(bean);
|
|
} catch (Exception ex) {
|
|
errorForm.setDataErrorException(ex);
|
|
log.error(ex.toString(), ex);
|
|
obj[0] = errorForm;
|
|
}
|
|
|
|
return obj;
|
|
}
|
|
} |