package xin.glue.nui.F.F02; import xin.glue.user.common.GlobalConstants; import xin.glue.user.common.LogGpError; import xin.glue.user.common.StringUtils; 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 MILLRollSplit (NIF024080) * Description MILL WORK INSTRUCTION SPLIT ROLL * Write By KIM SUNG HO * Date 2009-03-13 */ public class MILLRollSplit extends PosActivity implements GlobalConstants { public String runActivity(PosContext context) { long V_NEW_ROLL_EDT_SEQ = 0 ; long V_ROLL_SLAB_SEQ = 0 ; long V_NEW_ROLL_MANA_NO_CNT = 0 ; long V_STATUS_CD_CNT = 0 ; long V_COIL_STAT_CNT = 0; String V_ROLL_MANA_IC = "" ; String V_NEW_ROLL_MANA_NO = "" ; String V_NEW_ROLL_MANA_FL = "" ; PosMessage message = context.getMessage(); //ROLL_MANA_NO, SLAB_NO String P_ROLL_MANA_NO = (String)message.get("ROLL_MANA_NO"); String P_SLAB_NO = (String)message.get("SLAB_NO"); String P_REG_ID = (String)message.get("REG_ID"); if (P_ROLL_MANA_NO == null || P_ROLL_MANA_NO.equals("") || P_SLAB_NO == null || P_SLAB_NO.equals("")) { //MESSAGE ERROR --> PROGRAM EXIT throw new PosException("MILLRollSplit..ROLL_MANA_NO OR SLAB_NO IS NULL.."); } //ROLL_MANA_NO, SLAB_NO CHECK PosParameter param1 = new PosParameter(); param1.setWhereClauseParameter(0, P_ROLL_MANA_NO); param1.setWhereClauseParameter(1, P_SLAB_NO); PosRowSet RollManaNoChkVO = getDao("mesdao").find("NIF024080_RollManaNoChk.select",param1); RollManaNoChkVO.reset(); if (RollManaNoChkVO.hasNext()) { PosRow RollManaNoChkRow = RollManaNoChkVO.next(); V_ROLL_SLAB_SEQ = Long.parseLong((RollManaNoChkRow.getAttribute("ROLL_SLAB_SEQ")==null? "0":RollManaNoChkRow.getAttribute("ROLL_SLAB_SEQ")).toString()); } else { //MESSAGE ERROR --> PROGRAM EXIT throw new PosException("MILLRollSplit..ROLL_SLAB_SEQ IN ROLL_MANA_NO NOT FOUND.."); } //SELECT STATUS_CD CHECK PosParameter paramS = new PosParameter(); paramS.setWhereClauseParameter(0, P_ROLL_MANA_NO); paramS.setWhereClauseParameter(1, String.valueOf(V_ROLL_SLAB_SEQ)); PosRowSet RollSlabStatusChkVO = getDao("mesdao").find("NIF024080_RollSlabStatusChk.select",paramS); RollSlabStatusChkVO.reset(); if (RollSlabStatusChkVO.hasNext()) { PosRow RollSlabStatusChkRow = RollSlabStatusChkVO.next(); V_STATUS_CD_CNT = Long.parseLong((RollSlabStatusChkRow.getAttribute("STATUS_CD_CNT")==null? "0":RollSlabStatusChkRow.getAttribute("STATUS_CD_CNT")).toString()); V_COIL_STAT_CNT = Long.parseLong((RollSlabStatusChkRow.getAttribute("COIL_STAT_CNT")==null? "0":RollSlabStatusChkRow.getAttribute("COIL_STAT_CNT")).toString()); } else { V_STATUS_CD_CNT = 0; V_COIL_STAT_CNT = 0; } if (V_STATUS_CD_CNT != 0) { //MESSAGE ERROR --> PROGRAM EXIT throw new PosException("MILLRollSplit..STATUS_CD = 'B'.."); } if (V_COIL_STAT_CNT != 0) { //MESSAGE ERROR --> PROGRAM EXIT throw new PosException("°åÅ÷ÒÑÉÏÁÏ MILLRollSplit..COIL_STAT = '0'.."); } //MAX(ROLL_EDT_SEQ) SELECT PosRowSet RollEdtSeqMaxVO = getDao("mesdao").find("NIF024080_RollEdtSeqMax.select"); RollEdtSeqMaxVO.reset(); if (RollEdtSeqMaxVO.hasNext()) { PosRow RollEdtSeqMaxRow = RollEdtSeqMaxVO.next(); V_NEW_ROLL_EDT_SEQ = Long.parseLong((RollEdtSeqMaxRow.getAttribute("ROLL_EDT_SEQ")==null? "0":RollEdtSeqMaxRow.getAttribute("ROLL_EDT_SEQ")).toString()); V_NEW_ROLL_EDT_SEQ = V_NEW_ROLL_EDT_SEQ + 1; } else { //MESSAGE ERROR --> PROGRAM EXIT throw new PosException("MILLRollSplit..MAX(ROLL_EDT_SEQ) DATA NOT FOUND.."); } //V_NEW_ROLL_MANA_NO ADD 1 if (P_ROLL_MANA_NO.substring(1, 5) == "9999") { //ROLL_MANA_NO HEADER ALPHABET + 1 String nextSeqQr = "SELECT CHR(ASCII('" + P_ROLL_MANA_NO.substring(0, 1) + "')+1) ROLL_HEAD FROM DUAL"; PosRowSet nextSeqVO = getDao("mesdao").findByQueryStatement(nextSeqQr); nextSeqVO.reset(); PosRow nextSeqRow = nextSeqVO.next(); String V_ROLL_HEAD = (String)nextSeqRow.getAttribute("ROLL_HEAD"); V_NEW_ROLL_MANA_NO = V_ROLL_HEAD + "0001"; } else { V_ROLL_MANA_IC = StringUtils.calculateIntegerStringValue(P_ROLL_MANA_NO.substring(1, 5), 1); V_NEW_ROLL_MANA_NO = new StringBuffer(5).append(P_ROLL_MANA_NO.substring(0, 1)).append(V_ROLL_MANA_IC).toString(); } //INIT TEMP TABLE TBF02_CHG_ROLL TEMP TABLE getDao("mesdao").delete("NIF024080_ChgRollDel.delete"); //INSERT TEMP TABLE TBF02_CHG_ROLL PosParameter param2 = new PosParameter(); param2.setValueParamter(0, P_ROLL_MANA_NO); getDao("mesdao").insert("NIF024080_ChgRollIns.insert",param2); //------------------------------------------------------------------------------- //INSERT MILL INSTRUCTION LEVEL2 SEND PROCESS (DELETE INFORMATION)--------------- //------------------------------------------------------------------------------- //TBH06_L2_ROLL_UNIT_INS SEND PROCESS (DELETE INFORMATION) PosParameter param3 = new PosParameter(); param3.setValueParamter(0, P_ROLL_MANA_NO); getDao("mesdao").insert("NIF024080_L2ROLLDelSend.insert",param3); //TBH06_L2_RHT_INS SEND PROCESS (DELETE INFORMATION) PosParameter param4 = new PosParameter(); param4.setValueParamter(0, P_ROLL_MANA_NO); getDao("mesdao").insert("NIF024080_L2RHTDelSend.insert",param4); //TBH06_L2_MILL_INS SEND PROCESS (DELETE INFORMATION) PosParameter param5 = new PosParameter(); param5.setValueParamter(0, P_ROLL_MANA_NO); getDao("mesdao").insert("NIF024080_L2MILLDelSend.insert",param5); //SELECT NXET SET SEQUEANCE String nextSeqQr = "SELECT L2_COIL_NO_SET_SEQ.NEXTVAL SET_SEQ FROM DUAL "; PosRowSet nextSeqVO = getDao("mesdao").findByQueryStatement(nextSeqQr); nextSeqVO.reset(); PosRow nextSeqRow = nextSeqVO.next(); Number V_SET_SEQ = (Number)nextSeqRow.getAttribute("SET_SEQ"); //TBH06_L2_COIL_NO_INS SEND PROCESS (DELETE INFORMATION) PosParameter param6 = new PosParameter(); param6.setValueParamter(0, V_SET_SEQ); param6.setValueParamter(1, P_ROLL_MANA_NO); getDao("mesdao").insert("NIF024080_L2ROLLCOILDelSend.insert",param6); //------------------------------------------------------------------------------- //TBF02_SPEC_ROLL CHG_ROLL_MANA_NO --> ROLL_MANA_NO CHANGE PosParameter param7 = new PosParameter(); param7.setWhereClauseParameter(0, P_ROLL_MANA_NO); getDao("mesdao").update("NIF024080_SpecRollUpd.update",param7); //TBF02_SPEC_MILL CHG_ROLL_MANA_NO --> ROLL_MANA_NO CHANGE PosParameter param8 = new PosParameter(); param8.setWhereClauseParameter(0, P_ROLL_MANA_NO); getDao("mesdao").update("NIF024080_SpecMillUpd.update",param8); //TBF02_MILL_IDX CHG_ROLL_MANA_NO --> ROLL_MANA_NO CHANGE PosParameter param9 = new PosParameter(); param9.setWhereClauseParameter(0, P_ROLL_MANA_NO); getDao("mesdao").update("NIF024080_MillIdxUpd.update",param9); //------------------------------------------------------------------------------- //INSERT MILL INSTRUCTION LEVEL2 SEND PROCESS (UPDATE INFORMATION)--------------- //------------------------------------------------------------------------------- //TBH06_L2_ROLL_UNIT_INS SEND PROCESS (UPDATE INFORMATION) PosParameter paramA = new PosParameter(); paramA.setValueParamter(0, "2"); paramA.setValueParamter(1, P_ROLL_MANA_NO); paramA.setValueParamter(2, "Y"); getDao("mesdao").insert("NIF024080_L2ROLLUpdInsSend.insert",paramA); //TBH06_L2_RHT_INS SEND PROCESS (UPDATE INFORMATION) PosParameter paramB = new PosParameter(); paramB.setValueParamter(0, "2"); paramB.setValueParamter(1, P_ROLL_MANA_NO); paramB.setValueParamter(2, "Y"); getDao("mesdao").insert("NIF024080_L2RHTUpdInsSend.insert",paramB); //TBH06_L2_MILL_INS SEND PROCESS (UPDATE INFORMATION) PosParameter paramC = new PosParameter(); paramC.setValueParamter(0, "2"); paramC.setValueParamter(1, P_ROLL_MANA_NO); paramC.setValueParamter(2, "Y"); getDao("mesdao").insert("NIF024080_L2MILLUpdInsSend.insert",paramC); //SELECT NXET SET SEQUEANCE String nextSeqQrUpd = "SELECT L2_COIL_NO_SET_SEQ.NEXTVAL SET_SEQ FROM DUAL "; PosRowSet nextSeqUpdVO = getDao("mesdao").findByQueryStatement(nextSeqQrUpd); nextSeqUpdVO.reset(); PosRow nextSeqUpdRow = nextSeqUpdVO.next(); Number V_SET_SEQUpd = (Number)nextSeqUpdRow.getAttribute("SET_SEQ"); //TBH06_L2_COIL_NO_INS SEND PROCESS (UPDATE INFORMATION) PosParameter paramD = new PosParameter(); paramD.setValueParamter(0, V_SET_SEQUpd); paramD.setValueParamter(1, P_ROLL_MANA_NO); paramD.setValueParamter(2, "Y"); getDao("mesdao").insert("NIF024080_L2ROLLCOILUpdInsSend.insert",paramD); //------------------------------------------------------------------------------- //------------------------------------------------------------------------------- //INSERT MILL INSTRUCTION LEVEL2 SEND PROCESS (INSERT INFORMATION)--------------- //------------------------------------------------------------------------------- //TBH06_L2_ROLL_UNIT_INS SEND PROCESS (INSERT INFORMATION) PosParameter paramE = new PosParameter(); paramE.setValueParamter(0, "1"); paramE.setValueParamter(1, P_ROLL_MANA_NO); paramE.setValueParamter(2, "N"); getDao("mesdao").insert("NIF024080_L2ROLLUpdInsSend.insert",paramE); //TBH06_L2_RHT_INS SEND PROCESS (INSERT INFORMATION) PosParameter paramF = new PosParameter(); paramF.setValueParamter(0, "1"); paramF.setValueParamter(1, P_ROLL_MANA_NO); paramF.setValueParamter(2, "N"); getDao("mesdao").insert("NIF024080_L2RHTUpdInsSend.insert",paramF); //TBH06_L2_MILL_INS SEND PROCESS (INSERT INFORMATION) PosParameter paramG = new PosParameter(); paramG.setValueParamter(0, "1"); paramG.setValueParamter(1, P_ROLL_MANA_NO); paramG.setValueParamter(2, "N"); getDao("mesdao").insert("NIF024080_L2MILLUpdInsSend.insert",paramG); //SELECT NXET SET SEQUEANCE String nextSeqQrIns = "SELECT L2_COIL_NO_SET_SEQ.NEXTVAL SET_SEQ FROM DUAL "; PosRowSet nextSeqInsVO = getDao("mesdao").findByQueryStatement(nextSeqQrIns); nextSeqInsVO.reset(); PosRow nextSeqInsRow = nextSeqInsVO.next(); Number V_SET_SEQIns = (Number)nextSeqInsRow.getAttribute("SET_SEQ"); //TBH06_L2_COIL_NO_INS SEND PROCESS (INSERT INFORMATION) PosParameter paramH = new PosParameter(); paramH.setValueParamter(0, V_SET_SEQIns); paramH.setValueParamter(1, P_ROLL_MANA_NO); paramH.setValueParamter(2, "N"); getDao("mesdao").insert("NIF024080_L2ROLLCOILUpdInsSend.insert",paramH); //------------------------------------------------------------------------------- //------------------------------------------------------------------------------- //ROLL SPLIT PROCESS //------------------------------------------------------------------------------- //ROLL_EDT_SEQ SELECT PosParameter paramI = new PosParameter(); paramI.setWhereClauseParameter(0, V_NEW_ROLL_MANA_NO); PosRowSet RollEdtSeqVO = getDao("mesdao").find("NIF024080_NewRollManaNoSel.select",paramI); RollEdtSeqVO.reset(); if (RollEdtSeqVO.hasNext()) { //MESSAGE ERROR --> PROGRAM EXIT throw new PosException("MILLRollSplit..ALREADY EXIST NEW_ROLL_MANA_NO.." + V_NEW_ROLL_MANA_NO); } //UPDATE TBF02_SPEC_MILL ROLL_MANA_NO, ROLL_SLAB_SEQ PosParameter paramJ = new PosParameter(); paramJ.setWhereClauseParameter(0, V_NEW_ROLL_MANA_NO); paramJ.setWhereClauseParameter(1, P_ROLL_MANA_NO); paramJ.setWhereClauseParameter(2, String.valueOf(V_ROLL_SLAB_SEQ)); paramJ.setWhereClauseParameter(3, String.valueOf(V_NEW_ROLL_EDT_SEQ)); paramJ.setWhereClauseParameter(4, P_ROLL_MANA_NO); paramJ.setWhereClauseParameter(5, String.valueOf(V_ROLL_SLAB_SEQ)); getDao("mesdao").update("NIF024080_SpecMillNewUpd.update",paramJ); //UPDATE TBF02_MILL_IDX ROLL_MANA_NO, ROLL_SLAB_SEQ PosParameter paramK = new PosParameter(); paramK.setWhereClauseParameter(0, P_ROLL_MANA_NO); getDao("mesdao").update("NIF024080_MillIdxNewUpd.update",paramK); //UPDATE TBF02_SPEC_ROLL RE-ARRANGE PosParameter paramL = new PosParameter(); paramL.setWhereClauseParameter(0, P_ROLL_MANA_NO); paramL.setWhereClauseParameter(1, P_ROLL_MANA_NO); getDao("mesdao").update("NIF024080_SpecRollReArrange.update",paramL); //INSERT TBF02_SPEC_ROLL NEW ROLL_MANA_NO PosParameter paramM = new PosParameter(); paramM.setValueParamter(0, String.valueOf(V_NEW_ROLL_EDT_SEQ)); paramM.setValueParamter(1, V_NEW_ROLL_MANA_NO); paramM.setValueParamter(2, P_REG_ID); paramM.setValueParamter(3, V_NEW_ROLL_MANA_NO); getDao("mesdao").insert("NIF024080_SpecRollNewIns.insert",paramM); //------------------------------------------------------------------------------- //INSERT MILL INSTRUCTION LEVEL2 SEND PROCESS (UPDATE/INSERT INFORMATION)--------------- //------------------------------------------------------------------------------- //TBH06_L2_ROLL_UNIT_INS SEND PROCESS (UPDATE INFORMATION) PosParameter paramN = new PosParameter(); paramN.setValueParamter(0, "2"); paramN.setValueParamter(1, P_ROLL_MANA_NO); getDao("mesdao").insert("NIF024080_L2ROLLCurNewSend.insert",paramN); //SELECT NEW_ROLL_MANA_NO String newRollManaNo = "SELECT COUNT(ROLL_MANA_NO) ROLL_MANA_CNT FROM TBF02_CHG_ROLL WHERE ROLL_MANA_NO = '" + V_NEW_ROLL_MANA_NO + "' " ; PosRowSet newRollManaNoVO = getDao("mesdao").findByQueryStatement(newRollManaNo); newRollManaNoVO.reset(); PosRow newRollManaNoRow = newRollManaNoVO.next(); V_NEW_ROLL_MANA_NO_CNT = Long.parseLong((newRollManaNoRow.getAttribute("ROLL_MANA_CNT")==null? "0":newRollManaNoRow.getAttribute("ROLL_MANA_CNT")).toString()); if (V_NEW_ROLL_MANA_NO_CNT == 0) { V_NEW_ROLL_MANA_FL = "1"; } else { V_NEW_ROLL_MANA_FL = "2"; } //TBH06_L2_ROLL_UNIT_INS SEND PROCESS (INSERT INFORMATION) PosParameter paramO = new PosParameter(); paramO.setValueParamter(0, V_NEW_ROLL_MANA_FL); paramO.setValueParamter(1, V_NEW_ROLL_MANA_NO); getDao("mesdao").insert("NIF024080_L2ROLLCurNewSend.insert",paramO); //TBH06_L2_RHT_INS SEND PROCESS (UPDATE INFORMATION) PosParameter paramP = new PosParameter(); paramP.setValueParamter(0, V_NEW_ROLL_MANA_NO); getDao("mesdao").insert("NIF024080_L2RHTUpdSend.insert",paramP); //TBH06_L2_MILL_INS SEND PROCESS (UPDATE INFORMATION) PosParameter paramQ = new PosParameter(); paramQ.setValueParamter(0, V_NEW_ROLL_MANA_NO); getDao("mesdao").insert("NIF024080_L2MILLUpdSend.insert",paramQ); //SELECT NXET SET SEQUEANCE String nextSeqQr1 = "SELECT L2_COIL_NO_SET_SEQ.NEXTVAL SET_SEQ FROM DUAL "; PosRowSet nextSeq1VO = getDao("mesdao").findByQueryStatement(nextSeqQr1); nextSeq1VO.reset(); PosRow nextSeq1Row = nextSeq1VO.next(); Number V_SET_SEQ1 = (Number)nextSeq1Row.getAttribute("SET_SEQ"); //TBH06_L2_COIL_NO_INS SEND PROCESS (UPDATE INFORMATION) PosParameter paramR = new PosParameter(); paramR.setValueParamter(0, V_SET_SEQ1); paramR.setValueParamter(1, V_NEW_ROLL_MANA_NO); getDao("mesdao").insert("NIF024080_L2ROLLCOILUpdSend.insert",paramR); //------------------------------------------------------------------------------- //UPDATE TBF02_SPEC_ROLL FL = '' getDao("mesdao").update("NIF024080_SpecRollFLInt.update"); //UPDATE TBF02_SPEC_MILL FL = '' getDao("mesdao").update("NIF024080_SpecMillFLInt.update"); //UPDATE TBF02_MILL_IDX FL = '' getDao("mesdao").update("NIF024080_MillIdxFLInt.update"); //DELETE TBF02_CHG_ROLL getDao("mesdao").update("NIF024080_ChgRollDel.delete"); return PosBizControlConstants.SUCCESS; } }