package xin.glue.nui.E.E01; import xin.glue.user.common.GlobalConstants; import com.posdata.glue.PosException; import com.posdata.glue.biz.activity.PosActivity; import com.posdata.glue.biz.constants.PosBizControlConstants; import com.posdata.glue.biz.control.PosBizProvider; import com.posdata.glue.context.PosContext; import com.posdata.glue.dao.vo.PosParameter; import com.posdata.glue.dao.vo.PosRow; import com.posdata.glue.dao.vo.PosRowSet; import com.posdata.glue.msg.PosMessage; import xin.glue.user.common.LogGpError; /* Program Name SaveOrdSts (NIE012070) * Description ORDER STATUS EVENT LOGGING * Write By KIM SUNG HO * Date 2008-10-13 */ public class SaveOrdSts extends PosActivity implements GlobalConstants { public String runActivity(PosContext context) { String V_TABLE_ID = "" ; String V_TABLE_MODE = "" ; String V_ERR_DESC = "" ; String V_RTN_NAME = "" ; PosMessage message = context.getMessage(); String P_BEF_ORD_NO = (String)message.get("BEF_ORD_NO"); String P_BEF_ORD_SEQ = (String)message.get("BEF_ORD_SEQ"); String P_ORD_NO = (String)message.get("ORD_NO"); String P_ORD_SEQ = (String)message.get("ORD_SEQ"); String P_BEF_PROG_CD = (String)message.get("BEF_PROG_CD"); String P_PROG_CD = (String)message.get("PROG_CD"); String P_MAT_TYPE = (String)message.get("MAT_TYPE"); String P_MAT_NO = (String)message.get("MAT_NO"); Number P_WGT = (Number)message.get("WGT"); String P_PGMID = (String)message.get("PGMID"); String P_REG_ID = (String)message.get("REG_ID"); try { if (P_MAT_TYPE == null || "".equals(P_MAT_TYPE)) { V_RTN_NAME = "SaveOrdSts MAT_TYPE IS NULL "; throw new PosException(V_RTN_NAME); } if (P_MAT_NO == null || "".equals(P_MAT_NO)) { V_RTN_NAME = "SaveOrdSts MAT_NO IS NULL "; throw new PosException(V_RTN_NAME); } PosParameter param0 = new PosParameter(); PosRowSet rowset = null; PosRow row = null; if (P_MAT_TYPE.equals("CH")) { param0 = new PosParameter(); param0.setWhereClauseParameter(0, P_MAT_NO); rowset = getDao("mesdao").find("NIE012070_SLAB_RT_CHECK.select", param0); while(rowset.hasNext()){ row = rowset.next(); String slabRt = (String)row.getAttribute("SLAB_RT"); if(slabRt.equals("Z") || slabRt.equals("P")){ return PosBizControlConstants.SUCCESS; }else{ continue; } } } else if (P_MAT_TYPE.equals("TM")) { param0 = new PosParameter(); param0.setWhereClauseParameter(0, P_MAT_NO); rowset = getDao("mesdao").find("NIE012070_SLAB_RT_CHECK02.select", param0); while(rowset.hasNext()){ row = rowset.next(); String slabRt = (String)row.getAttribute("SLAB_RT"); if(slabRt.equals("Z") || slabRt.equals("P")){ return PosBizControlConstants.SUCCESS; }else{ continue; } } } //SELECT NXET SEQUEANCE FROM TBE02_ORDSTS String nextSeqQr = "SELECT ORDER_STATUS_OCC_SEQ.NEXTVAL NEXT_SEQ FROM DUAL "; PosRowSet nextSeqVO = getDao("mesdao").findByQueryStatement(nextSeqQr); nextSeqVO.reset(); PosRow nextSeqRow = nextSeqVO.next(); Number V_OCC_SEQ = (Number)nextSeqRow.getAttribute("NEXT_SEQ"); param0 = new PosParameter(); //SELECT PK CHECK FROM TBE02_ORDSTS String nextSeqChQr = "SELECT OCC_SEQ FROM TBE02_ORDSTS WHERE OCC_SEQ = ? "; param0.setWhereClauseParameter(0, V_OCC_SEQ); PosRowSet nextSeqChVO = getDao("mesdao").findByQueryStatement(nextSeqChQr, param0); if (nextSeqChVO.hasNext()) { PosParameter param1 = new PosParameter(); param1.setValueParamter(0 , P_BEF_ORD_NO); param1.setValueParamter(1 , P_BEF_ORD_SEQ); param1.setValueParamter(2 , P_ORD_NO); param1.setValueParamter(3 , P_ORD_SEQ); param1.setValueParamter(4 , P_BEF_PROG_CD); param1.setValueParamter(5 , P_PROG_CD); param1.setValueParamter(6 , P_MAT_TYPE); param1.setValueParamter(7 , P_MAT_NO); param1.setValueParamter(8 , P_WGT); param1.setValueParamter(9 , P_PGMID); param1.setValueParamter(10, P_REG_ID); param1.setValueParamter(11, V_OCC_SEQ); int UpdCnt = getDao("mesdao").update("NIE012070_ORDSTS.update",param1); if (UpdCnt == 0) { V_TABLE_ID = "TBE02_ORDSTS"; V_TABLE_MODE = "U"; V_ERR_DESC = "TBE02_ORDSTS UPDATE COUNT IS ZERO"; V_RTN_NAME = "SaveOrdSts TBE02_ORDSTS UPDATE " + V_OCC_SEQ; LogGpError.logMessageToDB("SaveOrdSts", V_TABLE_ID, V_TABLE_MODE, V_ERR_DESC, V_RTN_NAME); throw new PosException(V_RTN_NAME); } } else { PosParameter param2 = new PosParameter(); param2.setValueParamter(0 , V_OCC_SEQ); param2.setValueParamter(1 , P_BEF_ORD_NO); param2.setValueParamter(2 , P_BEF_ORD_SEQ); param2.setValueParamter(3 , P_ORD_NO); param2.setValueParamter(4 , P_ORD_SEQ); param2.setValueParamter(5 , P_BEF_PROG_CD); param2.setValueParamter(6 , P_PROG_CD); param2.setValueParamter(7 , P_MAT_TYPE); param2.setValueParamter(8 , P_MAT_NO); param2.setValueParamter(9 , P_WGT); param2.setValueParamter(10, P_PGMID); param2.setValueParamter(11, P_REG_ID); int InsCnt = getDao("mesdao").insert("NIE012070_ORDSTS.insert",param2); if (InsCnt == 0) { V_TABLE_ID = "TBE02_ORDSTS"; V_TABLE_MODE = "I"; V_ERR_DESC = "TBE02_ORDSTS INSERT COUNT IS ZERO"; V_RTN_NAME = "SaveOrdSts TBE02_ORDSTS INSERT " + V_OCC_SEQ; LogGpError.logMessageToDB("SaveOrdSts", V_TABLE_ID, V_TABLE_MODE, V_ERR_DESC, V_RTN_NAME); throw new PosException(V_RTN_NAME); } } } catch (PosException ex) { context.put(SERVICE_ERR_MSG, ex.getMessage()); throw ex; } catch (Throwable t) { context.put(SERVICE_ERR_MSG, t.getMessage()); throw new PosException(t.getMessage(), t); } return PosBizControlConstants.SUCCESS; } }