b9bef78edd46b903c6ab022672e10db869658dc9.svn-base 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. package xin.glue.ui.G.G04;
  2. import java.sql.CallableStatement;
  3. import java.text.SimpleDateFormat;
  4. import java.util.Date;
  5. import org.apache.commons.lang.StringUtils;
  6. import com.alibaba.fastjson.JSONArray;
  7. import com.alibaba.fastjson.JSONObject;
  8. import com.posdata.glue.biz.activity.PosActivity;
  9. import com.posdata.glue.biz.constants.PosBizControlConstants;
  10. import com.posdata.glue.context.PosContext;
  11. import com.posdata.glue.dao.PosGenericDao;
  12. import com.posdata.glue.dao.vo.PosParameter;
  13. import com.posdata.glue.dao.vo.PosRow;
  14. import com.posdata.glue.dao.vo.PosRowSet;
  15. public class XinSaveSlabYd extends PosActivity {
  16. public String runActivity(PosContext context) {
  17. String[] toBefStoreLoc =(String[]) context.get("TO_BEF_STORE_LOC");
  18. String[] toSlabNo =(String[]) context.get("TO_SLAB_NO");
  19. String[] toYardAddr =(String[]) context.get("TO_YARD_ADDR");
  20. String[] toStorelay =(String[]) context.get("TO_STORELAY");
  21. String[] fromyardAddr =(String[]) context.get("FROM_YARD_ADDR");
  22. String[] fromStorelay =(String[]) context.get("FROM_STORELAY");
  23. PosParameter param = new PosParameter();
  24. PosGenericDao dao = getDao("mesdao");
  25. YardHandle yardhand = new YardHandle(getDao("mesdao"));
  26. JSONObject hmOut = new JSONObject();
  27. JSONArray hmListOut = new JSONArray();
  28. JSONObject hmIn = new JSONObject();
  29. JSONArray hmListIn = new JSONArray();
  30. String nowDate = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
  31. if(toYardAddr == null || toYardAddr.length == 0 ||toYardAddr.length > 8)return PosBizControlConstants.SUCCESS;;
  32. for(int i = 0 ; i < toYardAddr.length ; i++){
  33. param = new PosParameter();
  34. param = new PosParameter();
  35. param.setWhereClauseParameter(0, toSlabNo[i]);
  36. PosRowSet rowSet = getDao("mesdao").find("UIG040061_MOVEALBE_SLAB.select", param);
  37. while(rowSet.hasNext()){
  38. PosRow row = rowSet.next();
  39. String slabStat = (String)row.getAttribute("SLAB_STAT");
  40. String missionClf = (String)row.getAttribute("MISSNO_CLF");
  41. String lstIngrCd = (String)row.getAttribute("LST_INGR_CD");
  42. String slabIngrGrd = (String)row.getAttribute("SLAB_INGR_DEC_GRD");
  43. String slabTotDecGrd = (String)row.getAttribute("SLAB_TOT_DEC_GRD");
  44. String slabOutTp = (String)row.getAttribute("SLAB_OUT_TP");
  45. if(slabStat.equals("3")){
  46. context.put("MESSAGES", " 板坯状态已经结束! ");
  47. return PosBizControlConstants.SUCCESS;
  48. }
  49. if(!(missionClf == null)&&(missionClf.equals("3") || missionClf.equals("2"))){
  50. context.put("MESSAGES", " 加回,轧回,吊销坯! ");
  51. return PosBizControlConstants.SUCCESS;
  52. }
  53. if(!slabOutTp.equals("Y")){
  54. context.put("MESSAGES", " 出库状态不允许出库,不能出库! ");
  55. return PosBizControlConstants.SUCCESS;
  56. }
  57. if(lstIngrCd == null){
  58. context.put("MESSAGES", " 无成份实绩,不能出库! ");
  59. return PosBizControlConstants.SUCCESS;
  60. }
  61. if(slabIngrGrd == null || (!slabIngrGrd.equals("1"))){
  62. if(slabTotDecGrd == null || !(slabTotDecGrd.equals("1") ||slabTotDecGrd.equals("3") ||slabTotDecGrd.equals("4") ||slabTotDecGrd.equals("9"))){
  63. context.put("MESSAGES", " 成份等级不合格,不能出库! ");
  64. return PosBizControlConstants.SUCCESS;
  65. }
  66. }
  67. if((StringUtils.isBlank(slabTotDecGrd))){
  68. context.put("MESSAGES", " 板坯未进行综合判定,不能出库! ");
  69. return PosBizControlConstants.SUCCESS;
  70. }
  71. }
  72. if(Integer.parseInt(toStorelay[i]) > 6){
  73. context.put("MESSAGES", " 台车垛位层数最大不得超过6层,移库失败");
  74. return PosBizControlConstants.SUCCESS;
  75. }
  76. if(toStorelay[i].length() < 2)toStorelay[i] = "0" + toStorelay[i];
  77. int updateCnt = yardhand.clearFromAddr(fromyardAddr[i], fromStorelay[i]);
  78. int updateCnt2 = yardhand.setToAddr(toSlabNo[i], fromyardAddr[i], fromStorelay[i], toYardAddr[i], toStorelay[i], "", "");
  79. int updateCnt3 = yardhand.setExtSlabComm(toSlabNo[i],fromyardAddr[i],fromStorelay[i],toYardAddr[i], toStorelay[i]);
  80. logger.logDebug("---------" + updateCnt + " updateCnt2= " + updateCnt2 + " uddateCnt3 = " + updateCnt3);
  81. String activityId = "",AppId = "",Exeejob = "";
  82. int flag = 1;
  83. //入热轧原料库
  84. if( (fromyardAddr[i].substring(0,1).equals("L") || (fromyardAddr[i].substring(0,1).equals("H") && !fromyardAddr[i].equals("H516"))
  85. || fromyardAddr[i].substring(0,2).equals("A0") || fromyardAddr[i].substring(0,2).equals("C0"))//在库跺位
  86. //出库跺位
  87. && (toYardAddr[i].substring(0,1).equals("Z") || toYardAddr[i].substring(0,1).equals("T") || toYardAddr[i].equals("H516"))
  88. ){
  89. hmOut = new JSONObject();
  90. hmOut.put("SLAB_NO", toSlabNo[i]);
  91. hmOut.put("LAYER", Integer.parseInt(toStorelay[i]));
  92. hmListOut.add(hmOut);
  93. activityId = "55A";
  94. AppId = "板坯入热轧库";
  95. Exeejob = "N";
  96. flag = 0;
  97. //配重自动审核
  98. CallableStatement cstm = null;
  99. try
  100. {
  101. cstm = this.getDao("mesdao").getCallableStatement("WEIGHT_CHECK.CAL");
  102. cstm.setString(1, toSlabNo[i]);
  103. cstm.registerOutParameter(2, java.sql.Types.VARCHAR);
  104. cstm.execute();
  105. //String err = cstm.getString(2);
  106. }catch(Exception ex){
  107. ex.printStackTrace();
  108. }
  109. finally{
  110. if(cstm != null){
  111. try{
  112. cstm.close();
  113. }catch(Exception e)
  114. {
  115. e.printStackTrace();
  116. }
  117. }
  118. }
  119. }
  120. //退库
  121. if( (fromyardAddr[i].substring(0,1).equals("T") || fromyardAddr[0].equals("H516") || fromyardAddr[i].substring(0,1).equals("Z"))
  122. && ((toYardAddr[i].substring(0,1).equals("L") || (toYardAddr[i].substring(0,1).equals("H") && !toYardAddr[i].substring(0,1).equals("H516"))
  123. || toYardAddr[i].substring(0,2).equals("A0") || toYardAddr[i].substring(0,2).equals("C0"))) ){
  124. activityId = "55A";
  125. AppId = "板坯退热轧库";
  126. Exeejob = "D";
  127. flag = 0;
  128. }
  129. //从板坯库移跺到台车的信息要发给1580 jiangxin 20240927
  130. if( fromyardAddr[i].substring(0,1).equals("Z") && toYardAddr[i].substring(0,1).equals("T")){
  131. hmIn = new JSONObject();
  132. hmIn.put("SLAB_NO", toSlabNo[i]);
  133. hmIn.put("LAYER", Integer.parseInt(toStorelay[i]));
  134. hmListIn.add(hmIn);
  135. }
  136. if(flag == 0){
  137. /*财务数据上抛*/
  138. CallableStatement cstm = null;
  139. try
  140. {
  141. cstm = this.getDao("mesdao").getCallableStatement("UPLOAD_DATA.CAL");
  142. cstm.setString(1, toSlabNo[i]);
  143. cstm.setString(2, activityId);
  144. cstm.setString(3, Exeejob);
  145. cstm.setString(4, AppId);
  146. cstm.setString(5, "3qrlzbp003");
  147. cstm.registerOutParameter(6, java.sql.Types.VARCHAR);
  148. cstm.execute();
  149. String err = cstm.getString(6);
  150. if(!org.apache.commons.lang.StringUtils.isBlank(cstm.getString(6))){
  151. context.put("MESSAGES","数据上传失败:" + err);
  152. return PosBizControlConstants.SUCCESS;
  153. }
  154. }catch(Exception ex){
  155. ex.printStackTrace();
  156. context.put("MESSAGES","Exception:" + ex.getMessage());
  157. return PosBizControlConstants.SUCCESS;
  158. }
  159. finally{
  160. if(cstm != null){
  161. try{
  162. cstm.close();
  163. }catch(Exception e)
  164. {
  165. e.printStackTrace();
  166. }
  167. }
  168. }
  169. }
  170. }
  171. //将数据发给1580系统
  172. //炼钢库上台车
  173. if(hmListOut.size() > 0){
  174. param = new PosParameter();
  175. param.setWhereClauseParameter(0, "I");//SLAB_NO
  176. param.setWhereClauseParameter(1, hmListOut.toString());
  177. param.setWhereClauseParameter(2, nowDate);
  178. dao.update("UIG04COMM_MEWM02.insert", param);
  179. }
  180. //板坯库上台车
  181. if(hmListIn.size() > 0){
  182. param = new PosParameter();
  183. param.setWhereClauseParameter(0, "O");//SLAB_NO
  184. param.setWhereClauseParameter(1, hmListIn.toString());
  185. param.setWhereClauseParameter(2, nowDate);
  186. dao.update("UIG04COMM_MEWM02.insert", param);
  187. }
  188. context.put("MESSAGES", " 操作成功! ");
  189. return PosBizControlConstants.SUCCESS;
  190. }
  191. }