package xin.glue.nui.F.F02; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import xin.glue.user.common.DateUtils; import xin.glue.user.common.GlobalConstants; import xin.glue.user.common.LogGpError; import com.posdata.glue.PosException; import com.posdata.glue.biz.activity.PosActivity; import com.posdata.glue.biz.constants.PosBizControlConstants; 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 java.lang.Long; /* Program Name MILLSchTme (NIF023040) * Description MILL WORK TIME SCHEDULE * Write By KIM SUNG HO * Date 2008-12-10 */ public class MILLSchTme extends PosActivity implements GlobalConstants { public String runActivity(PosContext context) { long V_SLAB_EDT_SEQ = 0 ; long V_FUR_TME = 0 ; long V_MILL_TME = 0 ; long C_ROLL_CHG_TIME = 30 ; String V_BEF_ROLL_MANA_NO = "" ; String V_ROLL_MANA_NO = "" ; String V_FUR_PRE_TME = "" ; String V_LST_MILL_PRE_TME = "" ; String V_TABLE_ID = "" ; String V_TABLE_MODE = "" ; String V_ERR_DESC = "" ; String V_RTN_NAME = "" ; PosMessage message = context.getMessage(); //START ROLL_MANA_NO/ROLL_SLAB_SEQ) String P_ROLL_MANA_NO = (String)message.get("ROLL_MANA_NO"); Number P_ROLL_SLAB_SEQ = (Number)message.get("ROLL_SLAB_SEQ"); // try { DateFormat formatter = new SimpleDateFormat("yyyyMMdd"); String currDate = formatter.format(new Date()); //ROLL_MANA_NO/ROLL_SLAB_SEQ CHECK if (P_ROLL_MANA_NO == null || P_ROLL_MANA_NO.equals("") || P_ROLL_SLAB_SEQ == null ) { //MESSAGE ERROR --> PROGRAM EXIT throw new PosException("MILLSchTme..ROLL_MANA_NO OR ROLL_SLAB_SEQ ERROR1.."); } //ROLL_MANA_NO/ROLL_SLAB_SEQ CHECK PosParameter param0 = new PosParameter(); param0.setWhereClauseParameter(0, P_ROLL_MANA_NO); param0.setWhereClauseParameter(1, String.valueOf(P_ROLL_SLAB_SEQ)); PosRowSet SlabChkVO = getDao("mesdao").find("NIF023040_SlabChk.select",param0); SlabChkVO.reset(); if (!SlabChkVO.hasNext()) { //MESSAGE ERROR --> PROGRAM EXIT throw new PosException("MILLSchTme..ROLL_MANA_NO OR ROLL_SLAB_SEQ ERROR2.."); } //LAST MILL_PRE_TME SELECT PosParameter param1 = new PosParameter(); param1.setWhereClauseParameter(0, P_ROLL_MANA_NO); param1.setWhereClauseParameter(1, String.valueOf(P_ROLL_SLAB_SEQ)); PosRowSet LstMillPreTmeVO = getDao("mesdao").find("NIF023040_LstMillPreTme.select",param1); LstMillPreTmeVO.reset(); if (LstMillPreTmeVO.hasNext()) { PosRow LstMillPreTmeRow = LstMillPreTmeVO.next(); V_LST_MILL_PRE_TME = (String)LstMillPreTmeRow.getAttribute("MILL_PRE_TME"); V_BEF_ROLL_MANA_NO = (String)LstMillPreTmeRow.getAttribute("ROLL_MANA_NO"); } else { V_LST_MILL_PRE_TME = currDate; V_BEF_ROLL_MANA_NO = ""; } //MILL TIME SCHEDULE SELECT SLAB PosParameter param2 = new PosParameter(); param2.setWhereClauseParameter(0, P_ROLL_MANA_NO); param2.setWhereClauseParameter(1, String.valueOf(P_ROLL_SLAB_SEQ)); PosRowSet RollSlabSelVO = getDao("mesdao").find("NIF023040_RollSlabSel.select",param2); RollSlabSelVO.reset(); while (RollSlabSelVO.hasNext()) { PosRow RollSlabSelRow = RollSlabSelVO.next(); V_ROLL_MANA_NO = (String)RollSlabSelRow.getAttribute("ROLL_MANA_NO"); V_SLAB_EDT_SEQ = Long.parseLong((RollSlabSelRow.getAttribute("SLAB_EDT_SEQ")==null? "0":RollSlabSelRow.getAttribute("SLAB_EDT_SEQ")).toString()); V_FUR_TME = Long.parseLong((RollSlabSelRow.getAttribute("FUR_TME")==null? "0":RollSlabSelRow.getAttribute("FUR_TME")).toString()); V_MILL_TME = Long.parseLong((RollSlabSelRow.getAttribute("MILL_TME")==null? "0":RollSlabSelRow.getAttribute("MILL_TME")).toString()); //ROLL CHANGE CHECK if (V_BEF_ROLL_MANA_NO.equals("") || V_BEF_ROLL_MANA_NO.equals(V_ROLL_MANA_NO)) { V_LST_MILL_PRE_TME = DateUtils.getStringDateAddedTime(V_LST_MILL_PRE_TME, 0, 0, (int)C_ROLL_CHG_TIME, 0); V_BEF_ROLL_MANA_NO = V_ROLL_MANA_NO; } //MILL/FUR SCHEDULE TIME V_LST_MILL_PRE_TME = DateUtils.getStringDateAddedTime(V_LST_MILL_PRE_TME, 0, 0, (int)V_MILL_TME, 0); V_FUR_PRE_TME = DateUtils.getStringDateAddedTime(V_LST_MILL_PRE_TME, 0, 0, (int)V_FUR_TME, 0); //MILL/FUR SCHEDULE TIME UPDATE PosParameter param3 = new PosParameter(); param3.setWhereClauseParameter(0, V_FUR_PRE_TME); param3.setWhereClauseParameter(1, V_LST_MILL_PRE_TME); param3.setWhereClauseParameter(2, String.valueOf(V_SLAB_EDT_SEQ)); int UpdCnt1 = getDao("mesdao").update("NIF023040_MillFurTme.update",param3); if (UpdCnt1 == 0) { V_TABLE_ID = "TBF02_SPEC_MILL"; V_TABLE_MODE = "U"; V_ERR_DESC = "TBF02_SPEC_MILL UPDATE COUNT IS ZERO"; V_RTN_NAME = "MILLSchTme TBF02_SPEC_MILL UPDATE1 " + String.valueOf(V_SLAB_EDT_SEQ); LogGpError.logMessageToDB("MILLSchTme", V_TABLE_ID, V_TABLE_MODE, V_ERR_DESC, V_RTN_NAME); throw new PosException(V_RTN_NAME); } } //RollSlabSelVO while END // } // 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; } }