package th.co.muangthai.endrprint.controller; import com.google.gson.reflect.TypeToken; 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.ENDR001Service; import th.co.muangthai.endrprint.model.bean.form.MsgErrorForm; import th.co.muangthai.endrprint.model.bean.form.SqlShowForm; import th.co.muangthai.endrprint.model.bean.form.data.PrintingDataForm; import th.co.muangthai.endrprint.model.bean.form.master.PrinterForm; import th.co.muangthai.endrprint.model.bean.form.master.TeamForm; import th.co.muangthai.endrprint.util.SessionUtil; import th.co.muangthai.endrprint.util.VSMUtil; import javax.servlet.http.HttpServletRequest; import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; /** * ENDR Print management. */ @Controller public class ENDR100Controller extends ENDR001Service { static Logger log = Logger.getLogger(ENDR100Controller.class); /** * Load the information/data to start (Master ,ComboBox) * @param request * @return Object[] search results */ @RequestMapping(value = "/json/ENDR100LoadData", method = RequestMethod.POST) public @ResponseBody Object[] loadData(HttpServletRequest request) { MsgErrorForm errorForm = new MsgErrorForm(); errorForm.setDataDefaultOk(); try { } catch (Exception ex) { errorForm.setDataErrorException(ex); log.error(ex.toString(), ex); } return new Object[]{errorForm}; } /** * ENDR Print information searching regarding the condition * @param request * @return Object[] search results */ @RequestMapping(value = "/json/ENDR100Process", method = RequestMethod.POST) public @ResponseBody Object[] schData(HttpServletRequest request) { MsgErrorForm errorForm = new MsgErrorForm(); errorForm.setDataDefaultOk(); List columnLst = new ArrayList(); List dataLst = new ArrayList(); try { // รับ Param จาก Pages String processTypeCode = request.getParameter("processTypeCodeParam"); String txtSql = request.getParameter("txtSqlParam"); String systemParam = request.getParameter("systemParam"); // PrintingDataForm schForm = gsonData.fromJson(schFormParam, PrintingDataForm.class); if (VSMUtil.isNotEmpty(processTypeCode) && VSMUtil.isNotEmpty(txtSql) && VSMUtil.isNotEmpty(systemParam)){ if ("WF".equals(systemParam)){ if("E".equals(processTypeCode)){ int x = commonService.executeTxtSql(txtSql); columnLst.add("Result Execute"); SqlShowForm bb = new SqlShowForm(); List g = new ArrayList(); if(1==x){ g.add("Success"); }else{ g.add("Not Success"); } bb.setDataRow(g); dataLst.add(bb); }else if ("U".equals(processTypeCode)){ // boolean z = commonService.executeTxtSqlUpdatePkg(txtSql); columnLst.add("Result Execute"); SqlShowForm bb = new SqlShowForm(); List g = new ArrayList(); if(z){ g.add("Success"); }else{ g.add("Not Success"); } bb.setDataRow(g); dataLst.add(bb); } else{ Object[] obj = commonService.searchTxtSql(txtSql); columnLst = (List)obj[0]; dataLst = (List)obj[1]; } }else { Object[] obj = commonService.searchTxtSqlEdas(txtSql); columnLst = (List)obj[0]; dataLst = (List)obj[1]; } } } catch (Exception ex) { // errorForm.setDataErrorException(ex); // log.error(ex.toString(), ex); } return new Object[]{errorForm ,columnLst,dataLst}; } }