f4a6afdb84e7c63fbd8545c2a2972e3f78beb712.svn-base 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  1. package xin.glue.nui.F.F01;
  2. import xin.glue.user.common.GlobalConstants;
  3. import xin.glue.user.common.LogGpError;
  4. import com.posdata.glue.PosException;
  5. import com.posdata.glue.biz.activity.PosActivity;
  6. import com.posdata.glue.biz.constants.PosBizControlConstants;
  7. import com.posdata.glue.biz.control.PosBizProvider;
  8. import com.posdata.glue.context.PosContext;
  9. import com.posdata.glue.dao.vo.PosParameter;
  10. import com.posdata.glue.dao.vo.PosRow;
  11. import com.posdata.glue.dao.vo.PosRowSet;
  12. import com.posdata.glue.msg.PosMESMessageImpl;
  13. import com.posdata.glue.msg.PosMessage;
  14. //import java.lang.Long;
  15. /* Program Name SMSSeqChange (NIF012120)
  16. * Description SMS WORK INSTRUCTION SEQUENCE CHANGING
  17. * Write By KIM SUNG HO
  18. * Date 2008-11-06
  19. */
  20. public class SMSSeqChange extends PosActivity implements GlobalConstants
  21. {
  22. public String runActivity(PosContext context)
  23. {
  24. long V_CHARGE_EDT_SEQ = 0;
  25. long V_CAST_CHARGE_SEQ = 0;
  26. long V_L2_ERR_CNT = 0;
  27. long V_STS_CNT = 0;
  28. long V_CHG_SEQ = 0;
  29. long V_CHG_SEQ_ST = 0;
  30. long V_CHG_SEQ_EN = 0;
  31. long V_CHG_SEQ_TG = 0;
  32. long V_ORG_SEQ = 0;
  33. long V_SHIFT_CNT = 0;
  34. long V_MOVE_CNT = 0;
  35. long V_SHIFT_FR_SEQ = 0;
  36. long V_SHIFT_TO_SEQ = 0;
  37. String V_CAST_MANA_ST = "";
  38. String V_CAST_MANA_EN = "";
  39. String V_CAST_MANA_TG = "";
  40. String V_CAST_MANA_NO = "";
  41. String V_CAST_MANA_NO_T = "";
  42. String V_TABLE_ID = "";
  43. String V_TABLE_MODE = "";
  44. String V_ERR_DESC = "";
  45. String V_RTN_NAME = "";
  46. PosMessage message = context.getMessage();
  47. String P_CHARGE_MANA_NO_ST = (String) message.get("CHARGE_MANA_NO_ST");
  48. String P_CHARGE_MANA_NO_EN = (String) message.get("CHARGE_MANA_NO_EN");
  49. String P_CHARGE_MANA_NO_TG = (String) message.get("CHARGE_MANA_NO_TG");
  50. String P_REG_ID = (String) message.get("REG_ID");
  51. //String PRC_LINE_ST = P_CHARGE_MANA_NO_ST.substring(3, 4);
  52. //String PRC_LINE_EN = P_CHARGE_MANA_NO_EN.substring(3, 4);
  53. //String PRC_LINE_TG = P_CHARGE_MANA_NO_TG.substring(3, 4);
  54. String PRC_LINE_ST = P_CHARGE_MANA_NO_ST.substring(2, 3);
  55. String PRC_LINE_EN = P_CHARGE_MANA_NO_EN.substring(2, 3);
  56. String PRC_LINE_TG = P_CHARGE_MANA_NO_TG.substring(2, 3);
  57. // try {
  58. // BOF LINE CHECK P_CHARGE_MANA_NO_ST, P_CHARGE_MANA_NO_EN
  59. if (!PRC_LINE_ST.equals(
  60. PRC_LINE_EN))
  61. {
  62. // MESSAGE ERROR --> PROGRAM EXIT
  63. throw new PosException("SMSSeqChange..BOF LINE DIFF ST/EN..");
  64. //errorDate(context,"SMSSeqChange..BOF LINE DIFF ST/EN..", "SMSSeqChange..BOF LINE DIFF ST/EN..");
  65. //return PosBizControlConstants.FAILURE;
  66. }
  67. // BOF LINE CHECK P_CHARGE_MANA_NO_ST,P_CHARGE_MANA_NO_TG
  68. if (!PRC_LINE_ST.equals(
  69. PRC_LINE_TG))
  70. {
  71. // MESSAGE ERROR --> PROGRAM EXIT
  72. throw new PosException("SMSSeqChange..BOF LINE DIFF ST/TG..");
  73. //errorDate(context,"SMSSeqChange..BOF LINE DIFF ST/TG..", "SMSSeqChange..BOF LINE DIFF ST/TG..");
  74. //return PosBizControlConstants.FAILURE;
  75. }
  76. // START/END/TARGET CAST_MANA_NO, CHG_SEQ CHECK
  77. PosParameter param0 = new PosParameter();
  78. param0.setWhereClauseParameter(0, P_CHARGE_MANA_NO_ST);
  79. param0.setWhereClauseParameter(1, P_CHARGE_MANA_NO_EN);
  80. param0.setWhereClauseParameter(2, P_CHARGE_MANA_NO_TG);
  81. PosRowSet CastManaNoSTVO = getDao("mesdao").find(
  82. "NIF012120_CastManaNo.select", param0);
  83. CastManaNoSTVO.reset();
  84. if (CastManaNoSTVO.hasNext())
  85. {
  86. PosRow CastManaNoSTRow = CastManaNoSTVO.next();
  87. V_CAST_MANA_ST = (String) CastManaNoSTRow
  88. .getAttribute("CAST_MANA_NO_ST");
  89. V_CAST_MANA_EN = (String) CastManaNoSTRow
  90. .getAttribute("CAST_MANA_NO_EN");
  91. V_CAST_MANA_TG = (String) CastManaNoSTRow
  92. .getAttribute("CAST_MANA_NO_TG");
  93. V_CHG_SEQ_ST = Long.parseLong((CastManaNoSTRow
  94. .getAttribute("CHG_SEQ_ST") == null ? "0" : CastManaNoSTRow
  95. .getAttribute("CHG_SEQ_ST")).toString());
  96. V_CHG_SEQ_EN = Long.parseLong((CastManaNoSTRow
  97. .getAttribute("CHG_SEQ_EN") == null ? "0" : CastManaNoSTRow
  98. .getAttribute("CHG_SEQ_EN")).toString());
  99. V_CHG_SEQ_TG = Long.parseLong((CastManaNoSTRow
  100. .getAttribute("CHG_SEQ_TG") == null ? "0" : CastManaNoSTRow
  101. .getAttribute("CHG_SEQ_TG")).toString());
  102. }
  103. else
  104. {
  105. V_CAST_MANA_ST = "";
  106. V_CAST_MANA_EN = "";
  107. V_CAST_MANA_TG = "";
  108. V_CHG_SEQ_ST = 0;
  109. V_CHG_SEQ_EN = 0;
  110. V_CHG_SEQ_TG = 0;
  111. }
  112. if (!V_CAST_MANA_ST.equals(V_CAST_MANA_EN))
  113. {
  114. // MESSAGE ERROR --> PROGRAM EXIT
  115. throw new PosException("SMSSeqChange..CAST_MANA DIFF ST/EN..");
  116. //errorDate(context,"SMSSeqChange..CAST_MANA DIFF ST/EN..", "SMSSeqChange..CAST_MANA DIFF ST/EN..");
  117. //return PosBizControlConstants.FAILURE;
  118. }
  119. if (V_CHG_SEQ_ST == 0 || V_CHG_SEQ_EN == 0 || V_CHG_SEQ_TG == 0
  120. || V_CHG_SEQ_ST > V_CHG_SEQ_EN)
  121. {
  122. // MESSAGE ERROR --> PROGRAM EXIT
  123. throw new PosException("SMSSeqChange..CHG_SEQ_ST OR CHG_SEQ_EN OR CHG_SEQ_TG IS ZERO..");
  124. //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..");
  125. //return PosBizControlConstants.FAILURE;
  126. }
  127. if (V_CHG_SEQ_ST <= V_CHG_SEQ_TG && V_CHG_SEQ_EN >= V_CHG_SEQ_TG)
  128. {
  129. // MESSAGE ERROR --> PROGRAM EXIT
  130. throw new PosException("SMSSeqChange..CHG_SEQ_ST <= CHG_SEQ_TG <= CHG_SEQ_EN..");
  131. //errorDate(context,"SMSSeqChange..CHG_SEQ_ST <= CHG_SEQ_TG <= CHG_SEQ_EN..", "SMSSeqChange..CHG_SEQ_ST <= CHG_SEQ_TG <= CHG_SEQ_EN..");
  132. //return PosBizControlConstants.FAILURE;
  133. }
  134. // SELECT COUNT(L2_SEND="Y"), COUNT(STATUS_CD="B","C") START/END
  135. PosParameter param5 = new PosParameter();
  136. param5.setWhereClauseParameter(0, PRC_LINE_ST);
  137. param5.setWhereClauseParameter(1, String.valueOf(V_CHG_SEQ_ST));
  138. param5.setWhereClauseParameter(2, String.valueOf(V_CHG_SEQ_EN));
  139. param5.setWhereClauseParameter(3, String.valueOf(V_CHG_SEQ_ST));
  140. param5.setWhereClauseParameter(4, String.valueOf(V_CHG_SEQ_EN));
  141. PosRowSet ChgCntChkVO = getDao("mesdao").find(
  142. "NIF012120_ChgCntChk.select", param5);
  143. ChgCntChkVO.reset();
  144. if (ChgCntChkVO.hasNext())
  145. {
  146. PosRow ChgCntChkRow = ChgCntChkVO.next();
  147. V_L2_ERR_CNT = Long
  148. .parseLong((ChgCntChkRow.getAttribute("L2_CNT") == null ? "0"
  149. : ChgCntChkRow.getAttribute("L2_CNT")).toString());
  150. V_STS_CNT = Long
  151. .parseLong((ChgCntChkRow.getAttribute("STATUS_CNT") == null ? "0"
  152. : ChgCntChkRow.getAttribute("STATUS_CNT"))
  153. .toString());
  154. if (V_L2_ERR_CNT != 0)
  155. {
  156. // MESSAGE ERROR --> PROGRAM EXIT
  157. throw new PosException("SMSSeqChange..L2_SEND = 'Y'..");
  158. }
  159. if (V_STS_CNT != 0)
  160. {
  161. // MESSAGE ERROR --> PROGRAM EXIT
  162. throw new PosException("SMSSeqChange..STATUS_CD = 'B','C'..");
  163. }
  164. }
  165. // SELECT COUNT(L2_SEND="Y"), COUNT(STATUS_CD="B","C") TARGET ~
  166. PosParameter paramA = new PosParameter();
  167. paramA.setWhereClauseParameter(0, PRC_LINE_ST);
  168. paramA.setWhereClauseParameter(1, String.valueOf(V_CHG_SEQ_TG));
  169. PosRowSet TGChgCntChkVO = getDao("mesdao").find(
  170. "NIF012120_TGChgCntChk.select", paramA);
  171. TGChgCntChkVO.reset();
  172. if (TGChgCntChkVO.hasNext())
  173. {
  174. PosRow TGChgCntChkRow = TGChgCntChkVO.next();
  175. V_L2_ERR_CNT = Long.parseLong((TGChgCntChkRow
  176. .getAttribute("L2_CNT") == null ? "0" : TGChgCntChkRow
  177. .getAttribute("L2_CNT")).toString());
  178. V_STS_CNT = Long.parseLong((TGChgCntChkRow
  179. .getAttribute("STATUS_CNT") == null ? "0" : TGChgCntChkRow
  180. .getAttribute("STATUS_CNT")).toString());
  181. if (V_L2_ERR_CNT != 0)
  182. {
  183. // MESSAGE ERROR --> PROGRAM EXIT
  184. throw new PosException("SMSSeqChange..TARGER ~ L2_SEND = 'Y'..");
  185. }
  186. if (V_STS_CNT != 0)
  187. {
  188. // MESSAGE ERROR --> PROGRAM EXIT
  189. throw new PosException(
  190. "SMSSeqChange..TARGER ~ STATUS_CD = 'B','C'..");
  191. }
  192. }
  193. // CHANGE RANGE VALUE SETTING
  194. if (V_CHG_SEQ_ST > V_CHG_SEQ_TG)
  195. {
  196. V_SHIFT_CNT = V_CHG_SEQ_EN - V_CHG_SEQ_ST + 1;
  197. V_MOVE_CNT = V_CHG_SEQ_TG - V_CHG_SEQ_ST + 1;
  198. V_SHIFT_FR_SEQ = V_CHG_SEQ_TG + 1;
  199. V_SHIFT_TO_SEQ = V_CHG_SEQ_ST - 1;
  200. }
  201. else
  202. {
  203. V_SHIFT_CNT = V_CHG_SEQ_ST - V_CHG_SEQ_EN - 1;
  204. V_MOVE_CNT = V_CHG_SEQ_TG - V_CHG_SEQ_EN;
  205. V_SHIFT_FR_SEQ = V_CHG_SEQ_EN + 1;
  206. V_SHIFT_TO_SEQ = V_CHG_SEQ_TG;
  207. }
  208. // SELECT TBF01_CHARGE_IDX RE_ARRANGE CHG_SEQ
  209. PosParameter param6 = new PosParameter();
  210. param6.setWhereClauseParameter(0, PRC_LINE_ST);
  211. PosRowSet ChgIdxVO = getDao("mesdao").find("NIF012120_ChgIdx.select",
  212. param6);
  213. ChgIdxVO.reset();
  214. while (ChgIdxVO.hasNext())
  215. {
  216. PosRow ChgIdxRow = ChgIdxVO.next();
  217. V_ORG_SEQ = Long
  218. .parseLong((ChgIdxRow.getAttribute("ORG_SEQ") == null ? "0"
  219. : ChgIdxRow.getAttribute("ORG_SEQ")).toString());
  220. V_CHG_SEQ = Long
  221. .parseLong((ChgIdxRow.getAttribute("CHG_SEQ") == null ? "0"
  222. : ChgIdxRow.getAttribute("CHG_SEQ")).toString());
  223. // CHECK SEQUENCE
  224. if (V_CHG_SEQ >= V_CHG_SEQ_ST && V_CHG_SEQ <= V_CHG_SEQ_EN)
  225. {
  226. V_CHG_SEQ = V_CHG_SEQ + V_MOVE_CNT;
  227. }
  228. else if (V_CHG_SEQ >= V_SHIFT_FR_SEQ && V_CHG_SEQ <= V_SHIFT_TO_SEQ)
  229. {
  230. V_CHG_SEQ = V_CHG_SEQ + V_SHIFT_CNT;
  231. }
  232. // TBF01_CHARGE_IDX UPDATE --> CHG_SEQ
  233. PosParameter param7 = new PosParameter();
  234. param7.setWhereClauseParameter(0, String.valueOf(V_CHG_SEQ));
  235. param7.setWhereClauseParameter(1, String.valueOf(V_ORG_SEQ));
  236. int UpdCnt3 = getDao("mesdao").update(
  237. "NIF012120_ChgSeqNoUpd.update", param7);
  238. if (UpdCnt3 == 0)
  239. {
  240. V_TABLE_ID = "TBF01_CHARGE_IDX";
  241. V_TABLE_MODE = "U";
  242. V_ERR_DESC = "TBF01_CHARGE_IDX UPDATE COUNT IS ZERO";
  243. V_RTN_NAME = "SMSSeqChange TBF01_CHARGE_IDX UPDATE3 "
  244. + String.valueOf(V_ORG_SEQ);
  245. LogGpError.logMessageToDB("SMSSeqChange", V_TABLE_ID,
  246. V_TABLE_MODE, V_ERR_DESC, V_RTN_NAME);
  247. throw new PosException(V_RTN_NAME);
  248. }
  249. } // ChgIdxVO while END
  250. // -----------------------------------------------------------------------------------
  251. // CALL NIF012180_SMSSchTme
  252. NIF012180_CALL(PRC_LINE_ST, P_REG_ID);
  253. // -----------------------------------------------------------------------------------
  254. // LAST L2 CAST_CHARGE_SEQ
  255. PosParameter param13 = new PosParameter();
  256. param13.setWhereClauseParameter(0, PRC_LINE_ST);
  257. param13.setWhereClauseParameter(1, PRC_LINE_ST);
  258. PosRowSet ChgManaLastVO = getDao("mesdao").find(
  259. "NIF012120_ChgManaLast.select", param13);
  260. ChgManaLastVO.reset();
  261. if (ChgManaLastVO.hasNext())
  262. {
  263. PosRow ChgManaLastRow = ChgManaLastVO.next();
  264. V_CAST_MANA_NO_T = (String) ChgManaLastRow
  265. .getAttribute("CAST_MANA_NO");
  266. V_CAST_CHARGE_SEQ = Long.parseLong((ChgManaLastRow
  267. .getAttribute("CAST_CHARGE_SEQ") == null ? "0"
  268. : ChgManaLastRow.getAttribute("CAST_CHARGE_SEQ"))
  269. .toString());
  270. }
  271. else
  272. {
  273. V_CAST_MANA_NO_T = V_CAST_MANA_ST;
  274. V_CAST_CHARGE_SEQ = 0;
  275. }
  276. // RE_ARRANGE UPDATE TBF01_SPEC_CHARGE -> CAST_CHARGE_SEQ
  277. PosParameter param14 = new PosParameter();
  278. param14.setWhereClauseParameter(0, V_CAST_MANA_NO_T);
  279. PosRowSet CastManaNoSeqVO = getDao("mesdao").find(
  280. "NIF012120_CastManaNoSeq.select", param14);
  281. CastManaNoSeqVO.reset();
  282. while (CastManaNoSeqVO.hasNext())
  283. {
  284. PosRow CastManaNoSeqRow = CastManaNoSeqVO.next();
  285. V_CAST_MANA_NO = (String) CastManaNoSeqRow
  286. .getAttribute("CAST_MANA_NO");
  287. V_CHARGE_EDT_SEQ = Long.parseLong((CastManaNoSeqRow
  288. .getAttribute("CHARGE_EDT_SEQ") == null ? "0"
  289. : CastManaNoSeqRow.getAttribute("CHARGE_EDT_SEQ"))
  290. .toString());
  291. // CAST_MANA_NO DIFFER
  292. if (V_CAST_MANA_NO_T.equals("")
  293. || !V_CAST_MANA_NO_T.equals(V_CAST_MANA_NO))
  294. {
  295. V_CAST_CHARGE_SEQ = 0;
  296. V_CAST_MANA_NO_T = V_CAST_MANA_NO;
  297. }
  298. ++V_CAST_CHARGE_SEQ;
  299. // UPDATE TBF01_SPEC_CHARGE -> CAST_CHARGE_SEQ
  300. PosParameter param16 = new PosParameter();
  301. param16.setWhereClauseParameter(0, String
  302. .valueOf(V_CAST_CHARGE_SEQ));
  303. param16
  304. .setWhereClauseParameter(1, String
  305. .valueOf(V_CHARGE_EDT_SEQ));
  306. int UpdCnt9 = getDao("mesdao").update(
  307. "NIF012120_ChargeSeqNo.update", param16);
  308. if (UpdCnt9 == 0)
  309. {
  310. V_TABLE_ID = "TBF01_SPEC_CHARGE";
  311. V_TABLE_MODE = "U";
  312. V_ERR_DESC = "TBF01_SPEC_CHARGE UPDATE COUNT IS ZERO";
  313. V_RTN_NAME = "SMSSeqChange TBF01_SPEC_CHARGE UPDATE9 "
  314. + String.valueOf(V_CHARGE_EDT_SEQ);
  315. LogGpError.logMessageToDB("SMSSeqChange", V_TABLE_ID,
  316. V_TABLE_MODE, V_ERR_DESC, V_RTN_NAME);
  317. throw new PosException(V_RTN_NAME);
  318. }
  319. } // ChgManaNoVO while END
  320. return PosBizControlConstants.SUCCESS;
  321. }
  322. /**
  323. * 参数错误处理
  324. *
  325. * @param context
  326. * @param logMsg
  327. * 打印到后台的日志信息
  328. * @param errorMsg
  329. * 返回到页面的提示信息
  330. */
  331. public void errorDate(PosContext context, String logMsg, String errorMsg)
  332. {
  333. logger.logInfo(logMsg);
  334. context.put("errorMsg", errorMsg);
  335. }
  336. public PosContext NIF012180_CALL(String V_PRC_LINE, String V_REG_ID)
  337. {
  338. PosContext context = new PosContext();
  339. PosMessage message = new PosMESMessageImpl();
  340. // SMSSchTme
  341. String TcId = "NIF012180";
  342. message.setTCID(TcId);
  343. message.setObject("MSG_ID", TcId);
  344. message.setObject("PRC_LINE", V_PRC_LINE);
  345. message.setObject("L2_SEND", "N");
  346. message.setObject("CHARGE_MANA_NO", "");
  347. message.setObject("REG_ID", V_REG_ID);
  348. context.setMessage(message);
  349. message.setTCID(TcId);
  350. String SERVICE_POSTFIX = "-service";
  351. context
  352. .put(PosBizControlConstants.SERVICE_NAME, TcId
  353. + SERVICE_POSTFIX);
  354. PosBizProvider.getController().doSubController(context, false);
  355. String SERVICE_ERR_MSG = (String) context.get("SERVICE_ERR_MSG");
  356. if (SERVICE_ERR_MSG != null)
  357. {
  358. throw new PosException(SERVICE_ERR_MSG);
  359. }
  360. return context;
  361. }
  362. }