d11e53554fa42d0b47ca2fdb3e0ee6f8952814a5.svn-base 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  1. package xin.glue.ui.G.G04;
  2. import java.math.BigDecimal;
  3. import java.sql.CallableStatement;
  4. import java.sql.SQLException;
  5. import java.text.DateFormat;
  6. import java.text.SimpleDateFormat;
  7. import java.util.Date;
  8. import org.apache.commons.lang.StringUtils;
  9. import com.posdata.glue.biz.activity.PosActivity;
  10. import com.posdata.glue.biz.constants.PosBizControlConstants;
  11. import com.posdata.glue.biz.control.PosBizControlIF;
  12. import com.posdata.glue.biz.control.PosBizProvider;
  13. import com.posdata.glue.component.PosConstants;
  14. import com.posdata.glue.context.PosContext;
  15. import com.posdata.glue.dao.PosGenericDao;
  16. import com.posdata.glue.dao.vo.PosParameter;
  17. import com.posdata.glue.dao.vo.PosRow;
  18. import com.posdata.glue.dao.vo.PosRowSet;
  19. import com.posdata.glue.msg.PosMESMessageImpl;
  20. import com.posdata.glue.msg.PosMessage;
  21. /**
  22. *
  23. * @auth: wangxiaoyan
  24. * @date: 2009-2-17
  25. * @desc: 板坯尺寸修改实绩
  26. */
  27. public class XinSaveCorrectSlab extends PosActivity {
  28. public String runActivity(PosContext context) {
  29. String SIZE_UPDT_CAUSE_CD = "01"; // RESIZE UPDATE
  30. String[] SLAB_THK = (String[])context.get("SLAB_THK");
  31. String[] SLAB_WTH = (String[])context.get("SLAB_WTH");
  32. String[] SLAB_LEN = (String[])context.get("SLAB_LEN");
  33. String[] SLAB_WGT = (String[])context.get("SLAB_WGT");
  34. String[] SIZE_DEC_FL = (String[])context.get("SLAB_SIZE_DEC_GRD");
  35. String[] SIZE_UPDT_WKSHIFT = (String[])context.get("REG_SHIP");
  36. String[] SIZE_UPDT_WKGROUP = (String[])context.get("REG_GROUP");
  37. String[] SIZE_UPDT_EMP_NO = (String[])context.get("REG_ID");
  38. String[] SCRAP_WGT = (String[])context.get("SCRAP_WGT");
  39. String[] SLAB_NO = (String[])context.get("SLAB_NO");
  40. //logger.logInfo("XinSaveCorrectSlab---> SIZE_UPDT_AFT_LEN:"+SIZE_UPDT_AFT_LEN[0] );
  41. PosParameter param1 = new PosParameter();
  42. param1.setWhereClauseParameter(0, SLAB_NO[0]);
  43. PosRowSet slabComVo = getDao("mesdao").find("UIG040070_04.select", param1);
  44. String OrdNo = null;
  45. String OrdSeq = null;
  46. String OrdFl = null;
  47. String CurProgCd = null;
  48. String BefProgCd = null;
  49. String BefOrdNo = null;
  50. String BefOrdSeq = null;
  51. String NonOrdResCd = "";
  52. String NonOrdResDate = "";
  53. String slabRt = null;
  54. String oldWTH = null;
  55. String oldLen = null;
  56. String oldThk = null;
  57. String StlGrd = null;
  58. String PlnOrdNo = null;
  59. String PlnSlabNo = null;
  60. if (slabComVo.hasNext()) {
  61. PosRow slabComROW = slabComVo.next();
  62. OrdNo = (String)slabComROW.getAttribute("ORD_NO");
  63. OrdSeq = (String)slabComROW.getAttribute("ORD_SEQ");
  64. CurProgCd = (String)slabComROW.getAttribute("CUR_PROG_CD");
  65. OrdFl = (String)slabComROW.getAttribute("ORD_FL");
  66. slabRt = (String)slabComROW.getAttribute("SLAB_RT");
  67. oldWTH = (String)slabComROW.getAttribute("SLAB_WTH");
  68. oldLen = (String)slabComROW.getAttribute("SLAB_LEN");
  69. oldThk = (String)slabComROW.getAttribute("SLAB_THK");
  70. StlGrd = (String)slabComROW.getAttribute("LG_STL_GRD");
  71. PlnSlabNo = (String)slabComROW.getAttribute("PLAN_SLAB_NO");
  72. }
  73. if(CurProgCd.equals("RBB")){
  74. context.put("MESSAGES", " 已经编入轧制计划,轧制吊销后才能修改! ");
  75. return PosBizControlConstants.SUCCESS;
  76. }
  77. if(SLAB_LEN == null || StringUtils.isBlank(SLAB_LEN[0]) || "0".equals(SLAB_LEN[0])){
  78. context.put("MESSAGES", "长度为空或不允许将板坯长度改为0!");
  79. return PosBizControlConstants.SUCCESS;
  80. }
  81. if(SLAB_WGT == null || StringUtils.isBlank(SLAB_WGT[0]) || "0".equals(SLAB_WGT[0])){
  82. context.put("MESSAGES", " 理重为空或不允许将板坯理重改为0!");
  83. return PosBizControlConstants.SUCCESS;
  84. }
  85. BefProgCd = CurProgCd;
  86. PosParameter param = new PosParameter();
  87. PosRowSet rowset = null;
  88. PosRow row = null;
  89. PosGenericDao dao = getDao("mesdao");
  90. String sql = "SELECT ORD_NO FROM TBF01_SPEC_SLAB T WHERE SLAB_MANA_NO = ?";
  91. param = new PosParameter();
  92. param.setWhereClauseParameter(0, PlnSlabNo);
  93. rowset = dao.findByQueryStatement(sql, param);
  94. if(rowset.hasNext()){
  95. row = rowset.next();
  96. PlnOrdNo = (String)row.getAttribute("ORD_NO");
  97. }
  98. if(slabRt != null && (slabRt.equals("Z")||slabRt.equals("P"))){
  99. if(PlnOrdNo != null && ("76".equals(PlnOrdNo.substring(0,2)) || "77".equals(PlnOrdNo.substring(0,2)) || "16".equals(PlnOrdNo.substring(0,2)))){
  100. if("1".equals(OrdFl))
  101. CurProgCd = "RGB";
  102. else
  103. if("W/Q".equals(StlGrd.substring(0,3)))
  104. CurProgCd = "RRC";
  105. else
  106. CurProgCd = "RGB";
  107. }else
  108. CurProgCd = "RGB";
  109. }else{
  110. CurProgCd = "RRC"; //板坯充当待机
  111. }
  112. /*String sql = "SELECT COILSTAT(T.SLAB_NO) STAT_FLAG FROM TBG02_SLAB_COMM T WHERE T.SLAB_NO = ?";
  113. param = new PosParameter();
  114. param.setWhereClauseParameter(0, SLAB_NO[0]);
  115. PosRowSet rowset = this.getDao("mesdao").findByQueryStatement(sql, param);
  116. if (rowset.hasNext())//查询库存信息 已出库板坯不允许改尺
  117. {
  118. PosRow row = rowset.next();
  119. String stat = (String)row.getAttribute("STAT_FLAG");//
  120. if("出库".equals(stat)){
  121. context.put("MESSAGES", SLAB_NO[0] + "板坯已出炼钢库,不允许进行改尺操作,请核实");
  122. return PosBizControlConstants.SUCCESS;
  123. }
  124. }*/
  125. if (OrdFl.equals("1")) {
  126. NonOrdResCd = "3A";
  127. DateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
  128. NonOrdResDate = formatter.format(new Date());
  129. }
  130. OrdFl = "2";
  131. BefOrdNo = OrdNo;
  132. BefOrdSeq = OrdSeq;
  133. OrdNo = null;
  134. OrdSeq = null;
  135. if(SLAB_NO.length > 0){
  136. //增加降级历史记录 20101227 wxy
  137. CallableStatement cstm = null;
  138. param = new PosParameter();
  139. try{
  140. cstm = this.getDao("mesdao").getCallableStatement("ORD_HIS_INSERT.call");
  141. cstm.setString(1, "B");
  142. cstm.setString(2, "S");
  143. cstm.setString(3, "");
  144. cstm.setString(4, "UIG040070");
  145. cstm.setString(5, "");
  146. cstm.setString(6, "");
  147. cstm.setString(7, "");
  148. cstm.setString(8, SLAB_NO[0]);
  149. cstm.setString(9, "TM");
  150. cstm.setString(10, "");
  151. cstm.setString(11, "");
  152. cstm.setString(12, "");
  153. cstm.setString(13, "");
  154. cstm.execute();
  155. }catch(Exception ex){
  156. logger.logError(ex.getMessage(), ex);
  157. }finally{
  158. if (cstm != null)
  159. {
  160. try
  161. {
  162. cstm.close();
  163. }
  164. catch (SQLException e)
  165. {
  166. logger.logWarn(e.getMessage(), e);
  167. }
  168. }
  169. }
  170. //end 增加降级历史记录
  171. //解决理重可能会出现空值的问题
  172. if(StringUtils.isBlank(SLAB_WGT[0])){
  173. SLAB_WGT[0] = Math.round(Double.parseDouble(SLAB_THK[0]) * Double.parseDouble(SLAB_WTH[0]) * Double.parseDouble(SLAB_LEN[0]) * 7.85 / 1000000) + "";
  174. }
  175. param.setWhereClauseParameter(0, SIZE_UPDT_CAUSE_CD);
  176. param.setWhereClauseParameter(1, SLAB_THK[0]);
  177. param.setWhereClauseParameter(2, SLAB_WTH[0]);
  178. param.setWhereClauseParameter(3, SLAB_LEN[0]);
  179. param.setWhereClauseParameter(4, SLAB_WGT[0]);
  180. param.setWhereClauseParameter(5, SLAB_THK[0]);
  181. param.setWhereClauseParameter(6, SLAB_WTH[0]);
  182. param.setWhereClauseParameter(7, SLAB_LEN[0]);
  183. param.setWhereClauseParameter(8, SLAB_WGT[0]);
  184. param.setWhereClauseParameter(9, SIZE_UPDT_WKSHIFT[0]);
  185. param.setWhereClauseParameter(10, SIZE_UPDT_WKGROUP[0]);
  186. param.setWhereClauseParameter(11, SIZE_UPDT_EMP_NO[0]);
  187. param.setWhereClauseParameter(12, SCRAP_WGT[0]);
  188. param.setWhereClauseParameter(13, NonOrdResCd);
  189. param.setWhereClauseParameter(14, NonOrdResDate);
  190. param.setWhereClauseParameter(15, CurProgCd);
  191. param.setWhereClauseParameter(16, SIZE_DEC_FL[0]);
  192. param.setWhereClauseParameter(17, SLAB_NO[0]);
  193. /*在热轧原料区域当修改铸坯厚度和宽度信息时铸坯重量不变,长度变化时重量一定改变
  194. * 在炼钢区域改任何规格都掉磅重*/
  195. if(!SLAB_LEN[0].equals(oldLen)){
  196. this.getDao("mesdao").update("UIG040070_SIZE_CORRECT_02.update", param);
  197. }else{
  198. this.getDao("mesdao").update("UIG040070_SIZE_CORRECT_02_01.update", param);
  199. }
  200. /*if(SLAB_THK[0].equals("230")){//针对热轧料该规格做单独处理
  201. if(!SLAB_WTH[0].equals(oldWTH)){//宽度发生变化的进行判断是否清除磅重
  202. if(SLAB_LEN[0].equals(oldLen)){//定尺不变只改宽度则不删除磅重
  203. this.getDao("mesdao").update("UIG040070_SIZE_CORRECT_02_01.update", param);
  204. }else{
  205. this.getDao("mesdao").update("UIG040070_SIZE_CORRECT_02.update", param);
  206. }
  207. }else{
  208. this.getDao("mesdao").update("UIG040070_SIZE_CORRECT_02.update", param);
  209. }
  210. }else{
  211. this.getDao("mesdao").update("UIG040070_SIZE_CORRECT_02.update", param);
  212. }*/
  213. /*//经计量部门与张卫协调后统一出库板坯修改定尺不改磅重
  214. int flag = 0;
  215. PosRowSet rowset = null;
  216. PosRow row = null;
  217. PosParameter paramx = new PosParameter();
  218. paramx.setWhereClauseParameter(0, SLAB_NO[0]);
  219. rowset = this.getDao("mesdao").findByQueryStatement("SELECT COILSTAT(?) KC FROM DUAL", paramx);
  220. if (rowset.hasNext())
  221. {
  222. row = rowset.next();
  223. String kc = (String)row.getAttribute("KC");
  224. if("在库".equals(kc))
  225. flag = 0;
  226. else
  227. flag = 1;
  228. }
  229. if(flag == 1)//不在库修改规格则不改磅重不改理重
  230. this.getDao("mesdao").update("UIG040070_SIZE_CORRECT_02_01.update", param);
  231. else{
  232. if(!SLAB_WTH[0].equals(oldWTH)){//宽度发生变化的进行判断是否清除磅重
  233. if(SLAB_LEN[0].equals(oldLen)){//定尺不变只改宽度则不删除磅重
  234. this.getDao("mesdao").update("UIG040070_SIZE_CORRECT_02_01.update", param);
  235. }else{
  236. this.getDao("mesdao").update("UIG040070_SIZE_CORRECT_02.update", param);
  237. }
  238. }else{
  239. this.getDao("mesdao").update("UIG040070_SIZE_CORRECT_02.update", param);
  240. }
  241. //this.getDao("mesdao").update("UIG040070_SIZE_CORRECT_02.update", param);
  242. }
  243. */
  244. PosParameter paramz = new PosParameter();
  245. paramz.setValueParamter(0, OrdFl);
  246. paramz.setValueParamter(1, SLAB_NO[0]);
  247. this.getDao("mesdao").update("UIG040070_SLAB_COMM_D.update",paramz);
  248. if (NonOrdResCd != null && !NonOrdResCd.equals("") ) {
  249. BigDecimal SlabWgt = new BigDecimal(SLAB_WGT[0]);
  250. SendProg_NIE012070(SLAB_NO[0],OrdNo,OrdSeq,BefOrdNo,BefOrdSeq,CurProgCd,BefProgCd,"TM",SlabWgt);
  251. SendProg_NIE012080();
  252. }
  253. /*财务数据上抛*/
  254. cstm = null;
  255. try
  256. {
  257. cstm = this.getDao("mesdao").getCallableStatement("UPLOAD_DATA.CAL");
  258. cstm.setString(1, SLAB_NO[0]);
  259. cstm.setString(2, "11AA");
  260. cstm.setString(3, "N");
  261. cstm.setString(4, "板坯改尺");
  262. cstm.setString(5, SIZE_UPDT_EMP_NO[0]);
  263. cstm.registerOutParameter(6, java.sql.Types.VARCHAR);
  264. cstm.execute();
  265. String err = cstm.getString(6);
  266. if(!org.apache.commons.lang.StringUtils.isBlank(cstm.getString(6))){
  267. context.put("MESSAGES","数据上传失败:" + err);
  268. return PosBizControlConstants.SUCCESS;
  269. }
  270. }catch(Exception ex){
  271. ex.printStackTrace();
  272. context.put("MESSAGES","Exception:" + ex.getMessage());
  273. return PosBizControlConstants.SUCCESS;
  274. }
  275. finally{
  276. if(cstm != null){
  277. try{
  278. cstm.close();
  279. }catch(Exception e)
  280. {
  281. e.printStackTrace();
  282. }
  283. }
  284. }
  285. }
  286. context.put("MESSAGES", " 修改成功! ");
  287. return PosBizControlConstants.SUCCESS;
  288. }
  289. public PosContext SendProg_NIE012070(String MatNo,String sOrdNo,String sOrdSeq,String sBefOrdNo,String sBefOrdSeq,String sProgCd,String BefProcCd,String sKind,BigDecimal nwgt )
  290. {
  291. PosContext context = new PosContext();
  292. PosMessage message = new PosMESMessageImpl();
  293. String TcId = "NIE012070";
  294. message.setTCID(TcId);
  295. message.setObject("MSG_ID",TcId);
  296. message.setObject("BEF_ORD_NO",sBefOrdNo);
  297. message.setObject("BEF_ORD_SEQ",sBefOrdSeq);
  298. message.setObject("ORD_NO",sOrdNo);
  299. message.setObject("ORD_SEQ",sOrdSeq);
  300. message.setObject("BEF_PROG_CD",BefProcCd);
  301. message.setObject("PROG_CD",sProgCd);
  302. message.setObject("MAT_TYPE",sKind);
  303. message.setObject("MAT_NO",MatNo);
  304. message.setObject("WGT", nwgt );
  305. message.setObject("PGMID","slabSizeCorrect");
  306. message.setObject("REG_ID","UIG040070");
  307. message.setTCID(TcId);
  308. context.setMessage(message);
  309. // this.processComponent(PosConstants.CREATE_MESSAGE, context);
  310. // String transactionCode = context.getMessage().getTC();
  311. String SERVICE_POSTFIX = "-service";
  312. context.put(PosBizControlConstants.SERVICE_NAME, TcId + SERVICE_POSTFIX);
  313. // context.setMessage(message);
  314. PosBizControlIF controller = PosBizProvider.getController();
  315. controller.doSubController(context,false);
  316. return null;
  317. }
  318. public void SendProg_NIE012080()
  319. {
  320. PosContext context = new PosContext();
  321. PosMessage message = new PosMESMessageImpl();
  322. String TcId = "NIE012080";
  323. message.setTCID(TcId);
  324. message.setObject("MSG_ID",TcId);
  325. message.setObject("AA",null);
  326. context.setMessage(message);
  327. this.processComponent(PosConstants.CREATE_MESSAGE, context);
  328. String transactionCode = context.getMessage().getTC();
  329. message.setTCID(TcId);
  330. String serviceName = "NIE012080";
  331. String SERVICE_POSTFIX = "-service";
  332. context.put(PosBizControlConstants.SERVICE_NAME, serviceName + SERVICE_POSTFIX);
  333. context.setMessage(message);
  334. PosBizControlIF controller = PosBizProvider.getController();
  335. controller.doSubController(context,false);
  336. }
  337. }