ecea9a2000429c712187862c8504af6eb50f9572.svn-base 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. package xin.glue.ui.G.G02;
  2. import java.math.BigDecimal;
  3. import java.sql.CallableStatement;
  4. import java.sql.SQLException;
  5. import java.sql.Types;
  6. import com.posdata.glue.PosException;
  7. import com.posdata.glue.biz.activity.PosActivity;
  8. import com.posdata.glue.biz.constants.PosBizControlConstants;
  9. import com.posdata.glue.biz.control.PosBizControlIF;
  10. import com.posdata.glue.biz.control.PosBizProvider;
  11. import com.posdata.glue.component.PosConstants;
  12. import com.posdata.glue.context.PosContext;
  13. import com.posdata.glue.dao.PosGenericDao;
  14. import com.posdata.glue.dao.vo.PosParameter;
  15. import com.posdata.glue.dao.vo.PosRow;
  16. import com.posdata.glue.dao.vo.PosRowSet;
  17. import com.posdata.glue.msg.PosMESMessageImpl;
  18. import com.posdata.glue.msg.PosMessage;
  19. import xin.glue.ui.common.PosDateFormat;
  20. /*
  21. * author:wangxiaoyan
  22. * Date:08-10-28
  23. * desc: 钢水回送实绩
  24. * DESC:090708 ADD 返送炉次计划自动下发 by sjw
  25. */
  26. public class XinSaveReturnCharge extends PosActivity
  27. {
  28. public String runActivity(PosContext context)
  29. {
  30. PosParameter param = null;
  31. PosRow row = null;
  32. PosRowSet rowset = null;
  33. PosGenericDao dao = getDao("mesdao");
  34. String[] MSG_CHRGE_NO = (String[])context.get("CHARGE_NO" );
  35. String[] MSG_PLAN_CHARGE_NO = (String[])context.get("PLAN_CHARGE_NO" );
  36. String[] MSG_RTN_CHARGE_OCR_PROC = (String[])context.get("RTN_CHARGE_OCR_PROC" );
  37. String[] MSG_RTN_CHARGE_OCR_DTIME = (String[])context.get("RTN_CHARGE_OCR_DTIME" );
  38. String[] MSG_RTN_CHARGE_WGT = (String[])context.get("RTN_CHARGE_WGT" );
  39. String[] MSG_RTN_CHARGE_CAUSE_CD = (String[])context.get("RTN_CHARGE_CAUSE_CD" );
  40. String P_NEW_CHARGE_MANA_NO = "";
  41. String P_RTN_MSG = "";
  42. String PGMID = "";
  43. BigDecimal chgWgt = new BigDecimal(MSG_RTN_CHARGE_WGT[0]);
  44. logger.logInfo("XinSaveReturnCharge---> MSG_PLAN_CHARGE_NO:"+MSG_PLAN_CHARGE_NO );
  45. param = new PosParameter();
  46. String getPlanChargeNo = "select plan_charge_no from tbg02_charge_comm where charge_no = ?";
  47. param.setWhereClauseParameter(0, MSG_CHRGE_NO[0]);
  48. rowset = dao.findByQueryStatement(getPlanChargeNo,param);
  49. if(rowset.hasNext()){
  50. row = rowset.next();
  51. MSG_PLAN_CHARGE_NO[0] = (String)row.getAttribute("PLAN_CHARGE_NO");
  52. }else{
  53. context.put("MESSAGES", " 无计划炉次号,操作失败! ");
  54. return PosBizControlConstants.SUCCESS;
  55. }
  56. /****************************炉次回送取消已编制的轧制计划*********************************************************/
  57. /**
  58. * ADD:090717
  59. * BY:SJW
  60. * DESC:如果编制了热送计划,则回送需要取消轧制计划
  61. */
  62. PosParameter param_hcr_mill_fl = new PosParameter();
  63. param_hcr_mill_fl.setWhereClauseParameter(0, MSG_CHRGE_NO[0]);
  64. PosRowSet mill_fl_vo = getDao("mesdao").find("NIG020630_HCR_MILL_FL.select", param_hcr_mill_fl);
  65. mill_fl_vo.reset();
  66. while (mill_fl_vo.hasNext() ) {
  67. PosRow mill_fl_row = mill_fl_vo.next();
  68. String lv_slab_no = (String)mill_fl_row.getAttribute("SLAB_NO");
  69. NIF024060_CALL(lv_slab_no,"XinSaveReturnCharge");
  70. }
  71. /***********************************************************************************************************/
  72. PosParameter param0 = new PosParameter();
  73. PosParameter param1 = new PosParameter();
  74. param1.setValueParamter(0,MSG_RTN_CHARGE_OCR_DTIME[0] );
  75. param1.setValueParamter(1,MSG_RTN_CHARGE_CAUSE_CD[0] );
  76. param1.setValueParamter(2,chgWgt );
  77. param1.setValueParamter(3,MSG_RTN_CHARGE_OCR_PROC[0] );
  78. param1.setValueParamter(4,MSG_CHRGE_NO[0] );
  79. // 修改炉次公共表
  80. this.getDao("mesdao").update("NIG020630_CHARGE_COM.update",param1);
  81. // Product control system table update
  82. // TBF01_SPEC_CHARGE,TBF01_CHARGE_IDX,TBF01_SPEC_SLAB,TBF01_SPEC_SLAB_D
  83. // if slab cutting result is existing then there are can not that's update
  84. param0.setWhereClauseParameter(0, MSG_PLAN_CHARGE_NO[0]);
  85. PosRowSet SpecChVo = getDao("mesdao").find("NIG020610_SLAB_SPEC.select", param0);
  86. while (SpecChVo.hasNext() ) {
  87. PosParameter paramA = new PosParameter();
  88. paramA.setWhereClauseParameter(0, MSG_PLAN_CHARGE_NO[0]);
  89. PosRowSet SlabVo = getDao("mesdao").find("NIG020610_SLAB_COMM.select", paramA);
  90. if (!SlabVo.hasNext()) {
  91. PosRow SpecChROW = SpecChVo.next();
  92. Number nSlabEdtSeq = (Number)SpecChROW.getAttribute("SLAB_EDT_SEQ");
  93. String SlabManaNo = (String)SpecChROW.getAttribute("SLAB_MANA_NO");
  94. PosParameter param2 = new PosParameter();
  95. param2.setValueParamter(0, "C" );
  96. param2.setValueParamter(1, SlabManaNo.substring(0,9) );
  97. this.getDao("mesdao").update("NIG020610_SPEC_SLAB.update", param2);
  98. PosParameter param3 = new PosParameter();
  99. param3.setValueParamter(0, "C" );
  100. param3.setValueParamter(1, nSlabEdtSeq );
  101. this.getDao("mesdao").update("NIG020610_SPEC_SLAB_D.update", param3);
  102. }
  103. }
  104. String CurProgCd = null;
  105. String BefProgCd = null;
  106. PosParameter param6 = new PosParameter();
  107. param6.setWhereClauseParameter(0, MSG_CHRGE_NO[0]);
  108. PosRowSet chComVo = getDao("mesdao").find("NIG020630_CHARGE_COM.select", param6);
  109. if (chComVo.hasNext()) {
  110. PosRow chComROW = chComVo.next();
  111. CurProgCd = (String)chComROW.getAttribute("CUR_PROG_CD");
  112. BefProgCd = (String)chComROW.getAttribute("BEF_PROG_CD");
  113. }
  114. PosParameter param4 = new PosParameter();
  115. param4.setValueParamter(0, "C");
  116. param4.setValueParamter(1, CurProgCd );
  117. param4.setValueParamter(2, MSG_PLAN_CHARGE_NO[0] );
  118. this.getDao("mesdao").update("NIG020610_SPEC_CHARGE.update", param4);
  119. PosParameter param5 = new PosParameter();
  120. param5.setValueParamter(0, "C" );
  121. param5.setValueParamter(1, MSG_PLAN_CHARGE_NO[0] );
  122. this.getDao("mesdao").update("NIG020610_SPEC_CHARGE_IDX.update", param5);
  123. PosParameter param7= new PosParameter();
  124. param7.setValueParamter(0, MSG_CHRGE_NO[0] );
  125. this.getDao("mesdao").update("NIG020630_SLAB_COMM.update", param7);
  126. PGMID = "XinSaveReturnCharge";
  127. // Progress system sub-service call
  128. SendProg_NIE012070( MSG_PLAN_CHARGE_NO[0],null,null,CurProgCd,BefProgCd,chgWgt,PGMID );
  129. SendProg_NIE012080();
  130. CallableStatement cStmt = null;
  131. try
  132. {
  133. cStmt = this.getDao("mesdao").getCallableStatement("CALL_RTN_CHARGE_AUTO");
  134. cStmt.setString(1,MSG_PLAN_CHARGE_NO[0]);
  135. cStmt.registerOutParameter(2, Types.VARCHAR);
  136. cStmt.registerOutParameter(3, Types.VARCHAR);
  137. cStmt.execute();
  138. P_NEW_CHARGE_MANA_NO = cStmt.getString(2);
  139. P_RTN_MSG = cStmt.getString(3);
  140. } catch (SQLException ex)
  141. {
  142. logger.logFatal("Can not execute PL/SQL",ex);
  143. throw new PosException("Can not execute PL/SQL >> " + P_RTN_MSG,ex);
  144. } finally
  145. {
  146. try
  147. {
  148. if(cStmt != null)
  149. {
  150. cStmt.close();
  151. }
  152. } catch (SQLException ex)
  153. {
  154. logger.logFatal("Can not Close CallableStatement Query ID [callTest]",ex);
  155. }
  156. }
  157. if(P_RTN_MSG == null || "".equals(P_RTN_MSG)) {
  158. ;
  159. } else {
  160. throw new PosException(P_RTN_MSG);
  161. }
  162. PGMID = "CALL_RTN_CHARGE_AUTO";
  163. SendProg_NIE012070(P_NEW_CHARGE_MANA_NO,null,null,"JBA","",chgWgt,PGMID );
  164. SendProg_NIE012080();
  165. context.put("MESSAGES", " 操作成功! ");
  166. return PosBizControlConstants.SUCCESS;
  167. }
  168. public PosContext SendProg_NIE012070(String MatNo,String sOrdNo,String sOrdSeq,String sCurProg,String sBefProg,BigDecimal wgt ,String V_PGM_ID )
  169. {
  170. logger.logInfo("XinSaveCcmResult SendProg_NIE012070 " );
  171. PosContext context = new PosContext();
  172. PosMessage message = new PosMESMessageImpl();
  173. String TcId = "NIE012070";
  174. message.setTCID(TcId);
  175. message.setObject("MSG_ID",TcId);
  176. message.setObject("BEF_ORD_NO",null);
  177. message.setObject("BEF_ORD_SEQ",null);
  178. message.setObject("ORD_NO",null);
  179. message.setObject("ORD_SEQ",null);
  180. message.setObject("BEF_PROG_CD",sBefProg);
  181. message.setObject("PROG_CD",sCurProg);
  182. message.setObject("MAT_TYPE","CH");
  183. message.setObject("MAT_NO",MatNo);
  184. message.setObject("WGT",wgt);
  185. message.setObject("PGMID",V_PGM_ID);
  186. message.setObject("REG_ID","LEVEL2");
  187. context.setMessage(message);
  188. this.processComponent(PosConstants.CREATE_MESSAGE, context);
  189. String transactionCode = context.getMessage().getTC();
  190. logger.logInfo("XinSaveCcmResult---> transactionCode:("+transactionCode+")" );
  191. message.setTCID(TcId);
  192. String serviceName = "NIE012070";
  193. String SERVICE_POSTFIX = "-service";
  194. context.put(PosBizControlConstants.SERVICE_NAME, serviceName + SERVICE_POSTFIX);
  195. context.setMessage(message);
  196. PosBizControlIF controller = PosBizProvider.getController();
  197. controller.doSubController(context,false);
  198. logger.logInfo("XinSaveCcmResult---> NIE012070 TC SendProgress end" );
  199. return null;
  200. }
  201. public PosContext SendProg_NIE012080()
  202. {
  203. logger.logInfo("XinSaveCcmResult SendProg_NIE012080 " );
  204. PosContext context = new PosContext();
  205. PosMessage message = new PosMESMessageImpl();
  206. String TcId = "NIE012080";
  207. message.setTCID(TcId);
  208. message.setObject("MSG_ID",TcId);
  209. message.setObject("AA",null);
  210. context.setMessage(message);
  211. this.processComponent(PosConstants.CREATE_MESSAGE, context);
  212. String transactionCode = context.getMessage().getTC();
  213. logger.logInfo("XinSaveChargeProc---> transactionCode:("+transactionCode+")" );
  214. message.setTCID(TcId);
  215. String serviceName = "NIE012080";
  216. String SERVICE_POSTFIX = "-service";
  217. context.put(PosBizControlConstants.SERVICE_NAME, serviceName + SERVICE_POSTFIX);
  218. context.setMessage(message);
  219. PosBizControlIF controller = PosBizProvider.getController();
  220. controller.doSubController(context,false);
  221. logger.logInfo("XinSaveChargeProc---> NIE012080 TC SendProgress end" );
  222. return null;
  223. }
  224. public PosContext NIF024060_CALL(String V_SLAB_NO, String V_REG_ID)
  225. {
  226. PosContext context = new PosContext();
  227. PosMessage message = new PosMESMessageImpl();
  228. String TcId = "NIF024060";
  229. message.setTCID(TcId);
  230. message.setObject("MSG_ID", TcId);
  231. message.setObject("TYPE", "M");
  232. message.setObject("FROM" , V_SLAB_NO);
  233. message.setObject("TO" , V_SLAB_NO);
  234. message.setObject("REG_ID", V_REG_ID );
  235. context.setMessage(message);
  236. message.setTCID(TcId);
  237. String SERVICE_POSTFIX = "-service";
  238. context.put(PosBizControlConstants.SERVICE_NAME, TcId + SERVICE_POSTFIX);
  239. PosBizProvider.getController().doSubController(context, false);
  240. String SERVICE_ERR_MSG = (String) context.get("SERVICE_ERR_MSG");
  241. if (SERVICE_ERR_MSG != null)
  242. {
  243. throw new PosException(SERVICE_ERR_MSG);
  244. }
  245. return context;
  246. }
  247. }