| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444 |
- package xin.glue.nui.F.F01;
- 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.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.PosMESMessageImpl;
- import com.posdata.glue.msg.PosMessage;
- //import java.lang.Long;
- /* Program Name SMSSeqChange (NIF012120)
- * Description SMS WORK INSTRUCTION SEQUENCE CHANGING
- * Write By KIM SUNG HO
- * Date 2008-11-06
- */
- public class SMSSeqChange extends PosActivity implements GlobalConstants
- {
- public String runActivity(PosContext context)
- {
- long V_CHARGE_EDT_SEQ = 0;
- long V_CAST_CHARGE_SEQ = 0;
- long V_L2_ERR_CNT = 0;
- long V_STS_CNT = 0;
- long V_CHG_SEQ = 0;
- long V_CHG_SEQ_ST = 0;
- long V_CHG_SEQ_EN = 0;
- long V_CHG_SEQ_TG = 0;
- long V_ORG_SEQ = 0;
- long V_SHIFT_CNT = 0;
- long V_MOVE_CNT = 0;
- long V_SHIFT_FR_SEQ = 0;
- long V_SHIFT_TO_SEQ = 0;
- String V_CAST_MANA_ST = "";
- String V_CAST_MANA_EN = "";
- String V_CAST_MANA_TG = "";
- String V_CAST_MANA_NO = "";
- String V_CAST_MANA_NO_T = "";
- String V_TABLE_ID = "";
- String V_TABLE_MODE = "";
- String V_ERR_DESC = "";
- String V_RTN_NAME = "";
- PosMessage message = context.getMessage();
- String P_CHARGE_MANA_NO_ST = (String) message.get("CHARGE_MANA_NO_ST");
- String P_CHARGE_MANA_NO_EN = (String) message.get("CHARGE_MANA_NO_EN");
- String P_CHARGE_MANA_NO_TG = (String) message.get("CHARGE_MANA_NO_TG");
- String P_REG_ID = (String) message.get("REG_ID");
- //String PRC_LINE_ST = P_CHARGE_MANA_NO_ST.substring(3, 4);
- //String PRC_LINE_EN = P_CHARGE_MANA_NO_EN.substring(3, 4);
- //String PRC_LINE_TG = P_CHARGE_MANA_NO_TG.substring(3, 4);
- String PRC_LINE_ST = P_CHARGE_MANA_NO_ST.substring(2, 3);
- String PRC_LINE_EN = P_CHARGE_MANA_NO_EN.substring(2, 3);
- String PRC_LINE_TG = P_CHARGE_MANA_NO_TG.substring(2, 3);
- // try {
- // BOF LINE CHECK P_CHARGE_MANA_NO_ST, P_CHARGE_MANA_NO_EN
- if (!PRC_LINE_ST.equals(
- PRC_LINE_EN))
- {
- // MESSAGE ERROR --> PROGRAM EXIT
- throw new PosException("SMSSeqChange..BOF LINE DIFF ST/EN..");
- //errorDate(context,"SMSSeqChange..BOF LINE DIFF ST/EN..", "SMSSeqChange..BOF LINE DIFF ST/EN..");
- //return PosBizControlConstants.FAILURE;
- }
- // BOF LINE CHECK P_CHARGE_MANA_NO_ST,P_CHARGE_MANA_NO_TG
- if (!PRC_LINE_ST.equals(
- PRC_LINE_TG))
- {
- // MESSAGE ERROR --> PROGRAM EXIT
- throw new PosException("SMSSeqChange..BOF LINE DIFF ST/TG..");
- //errorDate(context,"SMSSeqChange..BOF LINE DIFF ST/TG..", "SMSSeqChange..BOF LINE DIFF ST/TG..");
- //return PosBizControlConstants.FAILURE;
- }
- // START/END/TARGET CAST_MANA_NO, CHG_SEQ CHECK
- PosParameter param0 = new PosParameter();
- param0.setWhereClauseParameter(0, P_CHARGE_MANA_NO_ST);
- param0.setWhereClauseParameter(1, P_CHARGE_MANA_NO_EN);
- param0.setWhereClauseParameter(2, P_CHARGE_MANA_NO_TG);
- PosRowSet CastManaNoSTVO = getDao("mesdao").find(
- "NIF012120_CastManaNo.select", param0);
- CastManaNoSTVO.reset();
- if (CastManaNoSTVO.hasNext())
- {
- PosRow CastManaNoSTRow = CastManaNoSTVO.next();
- V_CAST_MANA_ST = (String) CastManaNoSTRow
- .getAttribute("CAST_MANA_NO_ST");
- V_CAST_MANA_EN = (String) CastManaNoSTRow
- .getAttribute("CAST_MANA_NO_EN");
- V_CAST_MANA_TG = (String) CastManaNoSTRow
- .getAttribute("CAST_MANA_NO_TG");
- V_CHG_SEQ_ST = Long.parseLong((CastManaNoSTRow
- .getAttribute("CHG_SEQ_ST") == null ? "0" : CastManaNoSTRow
- .getAttribute("CHG_SEQ_ST")).toString());
- V_CHG_SEQ_EN = Long.parseLong((CastManaNoSTRow
- .getAttribute("CHG_SEQ_EN") == null ? "0" : CastManaNoSTRow
- .getAttribute("CHG_SEQ_EN")).toString());
- V_CHG_SEQ_TG = Long.parseLong((CastManaNoSTRow
- .getAttribute("CHG_SEQ_TG") == null ? "0" : CastManaNoSTRow
- .getAttribute("CHG_SEQ_TG")).toString());
- }
- else
- {
- V_CAST_MANA_ST = "";
- V_CAST_MANA_EN = "";
- V_CAST_MANA_TG = "";
- V_CHG_SEQ_ST = 0;
- V_CHG_SEQ_EN = 0;
- V_CHG_SEQ_TG = 0;
- }
- if (!V_CAST_MANA_ST.equals(V_CAST_MANA_EN))
- {
- // MESSAGE ERROR --> PROGRAM EXIT
- throw new PosException("SMSSeqChange..CAST_MANA DIFF ST/EN..");
- //errorDate(context,"SMSSeqChange..CAST_MANA DIFF ST/EN..", "SMSSeqChange..CAST_MANA DIFF ST/EN..");
- //return PosBizControlConstants.FAILURE;
- }
- if (V_CHG_SEQ_ST == 0 || V_CHG_SEQ_EN == 0 || V_CHG_SEQ_TG == 0
- || V_CHG_SEQ_ST > V_CHG_SEQ_EN)
- {
- // MESSAGE ERROR --> PROGRAM EXIT
- throw new PosException("SMSSeqChange..CHG_SEQ_ST OR CHG_SEQ_EN OR CHG_SEQ_TG IS ZERO..");
- //errorDate(context,"SMSSeqChange..CHG_SEQ_ST OR CHG_SEQ_EN OR CHG_SEQ_TG IS ZERO..", "SMSSeqChange..CHG_SEQ_ST OR CHG_SEQ_EN OR CHG_SEQ_TG IS ZERO..");
- //return PosBizControlConstants.FAILURE;
- }
- if (V_CHG_SEQ_ST <= V_CHG_SEQ_TG && V_CHG_SEQ_EN >= V_CHG_SEQ_TG)
- {
- // MESSAGE ERROR --> PROGRAM EXIT
- throw new PosException("SMSSeqChange..CHG_SEQ_ST <= CHG_SEQ_TG <= CHG_SEQ_EN..");
- //errorDate(context,"SMSSeqChange..CHG_SEQ_ST <= CHG_SEQ_TG <= CHG_SEQ_EN..", "SMSSeqChange..CHG_SEQ_ST <= CHG_SEQ_TG <= CHG_SEQ_EN..");
- //return PosBizControlConstants.FAILURE;
- }
- // SELECT COUNT(L2_SEND="Y"), COUNT(STATUS_CD="B","C") START/END
- PosParameter param5 = new PosParameter();
- param5.setWhereClauseParameter(0, PRC_LINE_ST);
- param5.setWhereClauseParameter(1, String.valueOf(V_CHG_SEQ_ST));
- param5.setWhereClauseParameter(2, String.valueOf(V_CHG_SEQ_EN));
- param5.setWhereClauseParameter(3, String.valueOf(V_CHG_SEQ_ST));
- param5.setWhereClauseParameter(4, String.valueOf(V_CHG_SEQ_EN));
- PosRowSet ChgCntChkVO = getDao("mesdao").find(
- "NIF012120_ChgCntChk.select", param5);
- ChgCntChkVO.reset();
- if (ChgCntChkVO.hasNext())
- {
- PosRow ChgCntChkRow = ChgCntChkVO.next();
- V_L2_ERR_CNT = Long
- .parseLong((ChgCntChkRow.getAttribute("L2_CNT") == null ? "0"
- : ChgCntChkRow.getAttribute("L2_CNT")).toString());
- V_STS_CNT = Long
- .parseLong((ChgCntChkRow.getAttribute("STATUS_CNT") == null ? "0"
- : ChgCntChkRow.getAttribute("STATUS_CNT"))
- .toString());
- if (V_L2_ERR_CNT != 0)
- {
- // MESSAGE ERROR --> PROGRAM EXIT
- throw new PosException("SMSSeqChange..L2_SEND = 'Y'..");
- }
- if (V_STS_CNT != 0)
- {
- // MESSAGE ERROR --> PROGRAM EXIT
- throw new PosException("SMSSeqChange..STATUS_CD = 'B','C'..");
- }
- }
- // SELECT COUNT(L2_SEND="Y"), COUNT(STATUS_CD="B","C") TARGET ~
- PosParameter paramA = new PosParameter();
- paramA.setWhereClauseParameter(0, PRC_LINE_ST);
- paramA.setWhereClauseParameter(1, String.valueOf(V_CHG_SEQ_TG));
- PosRowSet TGChgCntChkVO = getDao("mesdao").find(
- "NIF012120_TGChgCntChk.select", paramA);
- TGChgCntChkVO.reset();
- if (TGChgCntChkVO.hasNext())
- {
- PosRow TGChgCntChkRow = TGChgCntChkVO.next();
- V_L2_ERR_CNT = Long.parseLong((TGChgCntChkRow
- .getAttribute("L2_CNT") == null ? "0" : TGChgCntChkRow
- .getAttribute("L2_CNT")).toString());
- V_STS_CNT = Long.parseLong((TGChgCntChkRow
- .getAttribute("STATUS_CNT") == null ? "0" : TGChgCntChkRow
- .getAttribute("STATUS_CNT")).toString());
- if (V_L2_ERR_CNT != 0)
- {
- // MESSAGE ERROR --> PROGRAM EXIT
- throw new PosException("SMSSeqChange..TARGER ~ L2_SEND = 'Y'..");
- }
- if (V_STS_CNT != 0)
- {
- // MESSAGE ERROR --> PROGRAM EXIT
- throw new PosException(
- "SMSSeqChange..TARGER ~ STATUS_CD = 'B','C'..");
- }
- }
- // CHANGE RANGE VALUE SETTING
- if (V_CHG_SEQ_ST > V_CHG_SEQ_TG)
- {
- V_SHIFT_CNT = V_CHG_SEQ_EN - V_CHG_SEQ_ST + 1;
- V_MOVE_CNT = V_CHG_SEQ_TG - V_CHG_SEQ_ST + 1;
- V_SHIFT_FR_SEQ = V_CHG_SEQ_TG + 1;
- V_SHIFT_TO_SEQ = V_CHG_SEQ_ST - 1;
- }
- else
- {
- V_SHIFT_CNT = V_CHG_SEQ_ST - V_CHG_SEQ_EN - 1;
- V_MOVE_CNT = V_CHG_SEQ_TG - V_CHG_SEQ_EN;
- V_SHIFT_FR_SEQ = V_CHG_SEQ_EN + 1;
- V_SHIFT_TO_SEQ = V_CHG_SEQ_TG;
- }
- // SELECT TBF01_CHARGE_IDX RE_ARRANGE CHG_SEQ
- PosParameter param6 = new PosParameter();
- param6.setWhereClauseParameter(0, PRC_LINE_ST);
- PosRowSet ChgIdxVO = getDao("mesdao").find("NIF012120_ChgIdx.select",
- param6);
- ChgIdxVO.reset();
- while (ChgIdxVO.hasNext())
- {
- PosRow ChgIdxRow = ChgIdxVO.next();
- V_ORG_SEQ = Long
- .parseLong((ChgIdxRow.getAttribute("ORG_SEQ") == null ? "0"
- : ChgIdxRow.getAttribute("ORG_SEQ")).toString());
- V_CHG_SEQ = Long
- .parseLong((ChgIdxRow.getAttribute("CHG_SEQ") == null ? "0"
- : ChgIdxRow.getAttribute("CHG_SEQ")).toString());
- // CHECK SEQUENCE
- if (V_CHG_SEQ >= V_CHG_SEQ_ST && V_CHG_SEQ <= V_CHG_SEQ_EN)
- {
- V_CHG_SEQ = V_CHG_SEQ + V_MOVE_CNT;
- }
- else if (V_CHG_SEQ >= V_SHIFT_FR_SEQ && V_CHG_SEQ <= V_SHIFT_TO_SEQ)
- {
- V_CHG_SEQ = V_CHG_SEQ + V_SHIFT_CNT;
- }
- // TBF01_CHARGE_IDX UPDATE --> CHG_SEQ
- PosParameter param7 = new PosParameter();
- param7.setWhereClauseParameter(0, String.valueOf(V_CHG_SEQ));
- param7.setWhereClauseParameter(1, String.valueOf(V_ORG_SEQ));
- int UpdCnt3 = getDao("mesdao").update(
- "NIF012120_ChgSeqNoUpd.update", param7);
- if (UpdCnt3 == 0)
- {
- V_TABLE_ID = "TBF01_CHARGE_IDX";
- V_TABLE_MODE = "U";
- V_ERR_DESC = "TBF01_CHARGE_IDX UPDATE COUNT IS ZERO";
- V_RTN_NAME = "SMSSeqChange TBF01_CHARGE_IDX UPDATE3 "
- + String.valueOf(V_ORG_SEQ);
- LogGpError.logMessageToDB("SMSSeqChange", V_TABLE_ID,
- V_TABLE_MODE, V_ERR_DESC, V_RTN_NAME);
- throw new PosException(V_RTN_NAME);
- }
- } // ChgIdxVO while END
- // -----------------------------------------------------------------------------------
- // CALL NIF012180_SMSSchTme
- NIF012180_CALL(PRC_LINE_ST, P_REG_ID);
- // -----------------------------------------------------------------------------------
- // LAST L2 CAST_CHARGE_SEQ
- PosParameter param13 = new PosParameter();
- param13.setWhereClauseParameter(0, PRC_LINE_ST);
- param13.setWhereClauseParameter(1, PRC_LINE_ST);
- PosRowSet ChgManaLastVO = getDao("mesdao").find(
- "NIF012120_ChgManaLast.select", param13);
- ChgManaLastVO.reset();
- if (ChgManaLastVO.hasNext())
- {
- PosRow ChgManaLastRow = ChgManaLastVO.next();
- V_CAST_MANA_NO_T = (String) ChgManaLastRow
- .getAttribute("CAST_MANA_NO");
- V_CAST_CHARGE_SEQ = Long.parseLong((ChgManaLastRow
- .getAttribute("CAST_CHARGE_SEQ") == null ? "0"
- : ChgManaLastRow.getAttribute("CAST_CHARGE_SEQ"))
- .toString());
- }
- else
- {
- V_CAST_MANA_NO_T = V_CAST_MANA_ST;
- V_CAST_CHARGE_SEQ = 0;
- }
- // RE_ARRANGE UPDATE TBF01_SPEC_CHARGE -> CAST_CHARGE_SEQ
- PosParameter param14 = new PosParameter();
- param14.setWhereClauseParameter(0, V_CAST_MANA_NO_T);
- PosRowSet CastManaNoSeqVO = getDao("mesdao").find(
- "NIF012120_CastManaNoSeq.select", param14);
- CastManaNoSeqVO.reset();
- while (CastManaNoSeqVO.hasNext())
- {
- PosRow CastManaNoSeqRow = CastManaNoSeqVO.next();
- V_CAST_MANA_NO = (String) CastManaNoSeqRow
- .getAttribute("CAST_MANA_NO");
- V_CHARGE_EDT_SEQ = Long.parseLong((CastManaNoSeqRow
- .getAttribute("CHARGE_EDT_SEQ") == null ? "0"
- : CastManaNoSeqRow.getAttribute("CHARGE_EDT_SEQ"))
- .toString());
- // CAST_MANA_NO DIFFER
- if (V_CAST_MANA_NO_T.equals("")
- || !V_CAST_MANA_NO_T.equals(V_CAST_MANA_NO))
- {
- V_CAST_CHARGE_SEQ = 0;
- V_CAST_MANA_NO_T = V_CAST_MANA_NO;
- }
- ++V_CAST_CHARGE_SEQ;
- // UPDATE TBF01_SPEC_CHARGE -> CAST_CHARGE_SEQ
- PosParameter param16 = new PosParameter();
- param16.setWhereClauseParameter(0, String
- .valueOf(V_CAST_CHARGE_SEQ));
- param16
- .setWhereClauseParameter(1, String
- .valueOf(V_CHARGE_EDT_SEQ));
- int UpdCnt9 = getDao("mesdao").update(
- "NIF012120_ChargeSeqNo.update", param16);
- if (UpdCnt9 == 0)
- {
- V_TABLE_ID = "TBF01_SPEC_CHARGE";
- V_TABLE_MODE = "U";
- V_ERR_DESC = "TBF01_SPEC_CHARGE UPDATE COUNT IS ZERO";
- V_RTN_NAME = "SMSSeqChange TBF01_SPEC_CHARGE UPDATE9 "
- + String.valueOf(V_CHARGE_EDT_SEQ);
- LogGpError.logMessageToDB("SMSSeqChange", V_TABLE_ID,
- V_TABLE_MODE, V_ERR_DESC, V_RTN_NAME);
- throw new PosException(V_RTN_NAME);
- }
- } // ChgManaNoVO while END
- return PosBizControlConstants.SUCCESS;
- }
- /**
- * 参数错误处理
- *
- * @param context
- * @param logMsg
- * 打印到后台的日志信息
- * @param errorMsg
- * 返回到页面的提示信息
- */
- public void errorDate(PosContext context, String logMsg, String errorMsg)
- {
- logger.logInfo(logMsg);
- context.put("errorMsg", errorMsg);
- }
- public PosContext NIF012180_CALL(String V_PRC_LINE, String V_REG_ID)
- {
- PosContext context = new PosContext();
- PosMessage message = new PosMESMessageImpl();
- // SMSSchTme
- String TcId = "NIF012180";
- message.setTCID(TcId);
- message.setObject("MSG_ID", TcId);
- message.setObject("PRC_LINE", V_PRC_LINE);
- message.setObject("L2_SEND", "N");
- message.setObject("CHARGE_MANA_NO", "");
- message.setObject("REG_ID", V_REG_ID);
- context.setMessage(message);
- message.setTCID(TcId);
- String SERVICE_POSTFIX = "-service";
- context
- .put(PosBizControlConstants.SERVICE_NAME, TcId
- + SERVICE_POSTFIX);
- PosBizProvider.getController().doSubController(context, false);
- String SERVICE_ERR_MSG = (String) context.get("SERVICE_ERR_MSG");
- if (SERVICE_ERR_MSG != null)
- {
- throw new PosException(SERVICE_ERR_MSG);
- }
- return context;
- }
- }
|