225a67540d1116d411af06e0cea150c48240a682.svn-base 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. package xin.glue.ui.G.G04;
  2. import java.math.BigDecimal;
  3. import java.util.HashMap;
  4. import java.util.Map;
  5. import xin.glue.ui.common.component.PosSiteLog;
  6. import com.posdata.glue.biz.activity.PosActivity;
  7. import com.posdata.glue.biz.constants.PosBizControlConstants;
  8. import com.posdata.glue.context.PosContext;
  9. import com.posdata.glue.dao.PosGenericDao;
  10. import com.posdata.glue.dao.vo.PosParameter;
  11. import com.posdata.glue.dao.vo.PosRow;
  12. import com.posdata.glue.dao.vo.PosRowSet;
  13. /*
  14. * ???陋?寧刻 C/R ????
  15. * 凜槨矜狼?????璂??,杰鹿菱?畇寧??
  16. * @author tangliang
  17. * @date 2008.11.03
  18. */
  19. public class CreateCrCommand extends PosActivity{
  20. private String currDate = null;
  21. private String R_SLAB_RT = null;
  22. private String R_HCR_CLF = null;
  23. private Number R_SLAB_WTH = null;
  24. private Number R_SLAB_LEN = null;
  25. private String R_ORD_NO = null;
  26. private String R_PRODNM_CD = null;
  27. private String R_STL_GRD = null;
  28. private String YD_SLAB_NO = null;
  29. private String YD_STL_GRD = null;
  30. private String YD_PRODNM_CD = null;
  31. private String YD_ORD_NO = null;
  32. private Number YD_SLAB_LEN = null;
  33. private Number YD_SLAB_WTH = null;
  34. private String YD_YARD_ADDR = null;
  35. private String YD_STORELAY = null;
  36. private String CrNo = null;
  37. public String runActivity(PosContext context)
  38. {
  39. String[] FROM_ADDR = (String[])context.get("FROM_ADDR");
  40. String[] SLAB_NO = (String[])context.get("SLAB_NO");
  41. String sEmpLoc = null;
  42. String sEmpClf = null;
  43. String sTrue = null;
  44. int SlabCnt = 0;
  45. SlabCnt = SLAB_NO.length;
  46. if ( SlabCnt > 0) {
  47. for ( int i = 0;i < 10; i++) {
  48. currDate = null;
  49. R_SLAB_RT = null;
  50. R_HCR_CLF = null;
  51. R_SLAB_WTH = null;
  52. R_SLAB_LEN = null;
  53. R_ORD_NO = null;
  54. R_PRODNM_CD = null;
  55. R_STL_GRD = null;
  56. YD_SLAB_NO = null;
  57. YD_STL_GRD = null;
  58. YD_PRODNM_CD = null;
  59. YD_ORD_NO = null;
  60. YD_SLAB_LEN = null;
  61. YD_SLAB_WTH = null;
  62. YD_YARD_ADDR = null;
  63. YD_STORELAY = null;
  64. CrNo = null;
  65. // 根据板坯号查询板坯参数信息
  66. PosParameter param0 = new PosParameter();
  67. param0.setWhereClauseParameter(0, SLAB_NO[i]);
  68. PosRowSet SLabComVO = getDao("mesdao").find("NIG020640_SLAB_COMM.select", param0);
  69. if(SLabComVO.hasNext()) {
  70. PosRow SLabComRow = SLabComVO.next();
  71. R_SLAB_RT = (String)SLabComRow.getAttribute("SLAB_WAY");
  72. R_HCR_CLF = (String)SLabComRow.getAttribute("HCR_CLF");
  73. R_SLAB_WTH = (Number)SLabComRow.getAttribute("SLAB_WTH");
  74. R_SLAB_LEN = (Number)SLabComRow.getAttribute("SLAB_LEN");
  75. R_ORD_NO = (String)SLabComRow.getAttribute("ORD_NO");
  76. R_PRODNM_CD = (String)SLabComRow.getAttribute("PRODNM_CD");
  77. R_STL_GRD = (String)SLabComRow.getAttribute("STL_GRD");
  78. // 查询对应板坯可以在热轧板坯库第一跨的堆放位置
  79. PosParameter param1 = new PosParameter();
  80. param1.setWhereClauseParameter(0, SLAB_NO[i]);
  81. PosRowSet maxStoVO = getDao("mesdao").find("NIG020640_STLGRD.select", param1);
  82. while(maxStoVO.hasNext()){
  83. PosRow maxStoROW = maxStoVO.next();
  84. String YARD_ADDR = (String)maxStoROW.getAttribute("YARD_ADDR");
  85. String YARD_COND_CLF = (String)maxStoROW.getAttribute("YARD_COND_CLF");
  86. PosParameter param2 = new PosParameter();
  87. param2.setWhereClauseParameter(0, YARD_ADDR);
  88. param2.setWhereClauseParameter(1, YARD_ADDR);
  89. // 查询一个跺位已经堆放的板坯中,最上面那块的板坯信息
  90. PosRowSet SlabYardVo = getDao("mesdao").find("NIG020640_SLAB_YARD.select", param2);
  91. if (SlabYardVo.hasNext()) {
  92. PosRow SlabYardROW = SlabYardVo.next();
  93. YD_SLAB_NO = (String)SlabYardROW.getAttribute("SLAB_NO");
  94. YD_STL_GRD = (String)SlabYardROW.getAttribute("STL_GRD");
  95. YD_PRODNM_CD = (String)SlabYardROW.getAttribute("PRODNM_CD");
  96. YD_ORD_NO = (String)SlabYardROW.getAttribute("ORD_NO");
  97. YD_SLAB_LEN = (Number)SlabYardROW.getAttribute("SLAB_LEN");
  98. YD_SLAB_WTH = (Number)SlabYardROW.getAttribute("SLAB_WTH");
  99. YD_YARD_ADDR = (String)SlabYardROW.getAttribute("YARD_ADDR");
  100. YD_STORELAY = (String)SlabYardROW.getAttribute("STORELAY");
  101. // 如果一个跺位的板坯堆放超过15块,因为最多只能堆放16块,则该跺位不能继续堆放
  102. int intYdStore = Integer.parseInt(YD_STORELAY);
  103. if (intYdStore > 15 ){
  104. break;
  105. }
  106. String sSel = compSlab(SLAB_NO[i],R_STL_GRD);
  107. if (sSel != null && sSel.equals("S")) {
  108. sTrue = CreCrComand( YD_YARD_ADDR,YD_STORELAY,YARD_COND_CLF);
  109. break;
  110. }
  111. } else {
  112. sEmpLoc = YARD_ADDR;
  113. sEmpClf = YARD_COND_CLF;
  114. }
  115. if (sTrue == null && sEmpLoc != null ) {
  116. sTrue = CreCrComand( sEmpLoc,"01",sEmpClf);
  117. String SlabWay = sEmpLoc.substring(0,2);
  118. }
  119. context.put("YARD_ADDR"+i,YARD_ADDR);
  120. context.put("CR_NO"+i,CrNo);
  121. }
  122. }
  123. }
  124. }
  125. return PosBizControlConstants.SUCCESS;
  126. }
  127. public String compSlab(String sSlabNo,String sStlGrd)
  128. {
  129. logger.logInfo("XinDecToPosition compSlab start " );
  130. double tol = 5;
  131. double D_R_SLAB_WTH = R_SLAB_WTH.doubleValue();
  132. logger.logInfo("XinDecToPosition compSlab D_R_SLAB_WTH:"+D_R_SLAB_WTH );
  133. double D_R_SLAB_LEN = R_SLAB_LEN.doubleValue();
  134. logger.logInfo("XinDecToPosition compSlab D_R_SLAB_LEN:"+D_R_SLAB_LEN );
  135. double D_YD_SLAB_LEN = YD_SLAB_LEN.doubleValue();
  136. double D_YD_SLAB_WTH = YD_SLAB_WTH.doubleValue();
  137. logger.logInfo("XinDecToPosition compSlab D_YD_SLAB_WTH:"+D_YD_SLAB_WTH );
  138. double rem_len = Math.abs(D_YD_SLAB_LEN - D_R_SLAB_LEN);
  139. double rem_wth = Math.abs(D_R_SLAB_WTH - D_YD_SLAB_WTH);
  140. logger.logInfo("XinDecToPosition compSlab rem_wth:"+rem_wth );
  141. logger.logInfo("XinDecToPosition compSlab rem_len:"+rem_len );
  142. String sRChargeNo = sSlabNo.substring(0,10);
  143. String sYChargeNo = YD_SLAB_NO.substring(0,10);
  144. logger.logInfo("XinDecToPosition compSlab sYChargeNo:"+sYChargeNo );
  145. Number aa = (Number) new Double(rem_len);
  146. if (rem_len > tol ) {
  147. logger.logInfo("XinDecToPosition compSlab rem_len> tol " );
  148. return "";
  149. }
  150. logger.logInfo("XinDecToPosition compSlab rem_len comp " );
  151. if (rem_wth > tol ) {
  152. return "";
  153. }
  154. //同订单,同牌号,同炉次的板坯可以放一起
  155. if ( R_ORD_NO.equals(YD_ORD_NO) && sStlGrd.equals(YD_STL_GRD) ) {
  156. return "S";
  157. }
  158. if ( R_ORD_NO.equals(YD_ORD_NO) ) {
  159. return "S";
  160. }
  161. if ( sStlGrd.equals(YD_STL_GRD) ) {
  162. return "S";
  163. }
  164. if ( sRChargeNo.equals(sYChargeNo) ) {
  165. return "S";
  166. }
  167. return "";
  168. }
  169. public String CreCrComand( String YardAddr,String Storelay,String YardClf)
  170. {
  171. logger.logInfo("XinDecToPosition--->CreCrComand: start" );
  172. String nOrdSeq = null;
  173. int iSeq = 0;
  174. PosRowSet YardCommandVo = getDao("mesdao").find("NIG020640_YARD_COMMAND.select", null);
  175. if ( YardCommandVo.hasNext() ) {
  176. PosRow YardCommandROW = YardCommandVo.next();
  177. nOrdSeq = (String)YardCommandROW.getAttribute("ORD_SEQ");
  178. iSeq = Integer.parseInt(nOrdSeq);
  179. iSeq = iSeq + 1;
  180. } else {
  181. iSeq = 1 ;
  182. }
  183. String Areas = YardAddr.substring(2,3);
  184. if (Areas.equals("1")) {
  185. CrNo = "1-2";
  186. } else {
  187. CrNo = "1-1";
  188. }
  189. logger.logInfo("XinDecToPosition--->CrNo:"+ CrNo );
  190. String sSeqNo = String.valueOf(iSeq);
  191. PosParameter param1 = new PosParameter();
  192. param1.setValueParamter(0, sSeqNo);
  193. param1.setValueParamter(1, YardClf);
  194. param1.setValueParamter(2, Storelay);
  195. param1.setValueParamter(3, CrNo);
  196. param1.setValueParamter(4, YardAddr);
  197. param1.setValueParamter(5, YardClf);
  198. getDao("mesdao").update("NIG020640_YARD_COMMAND.insert",param1);
  199. return "t";
  200. }
  201. }